コード例 #1
0
        public GameItemForm(GameLevelDescription currentLevel)
        {
            this.currentLevel = currentLevel;
            InitializeComponent();

            translationAmountPicker.DecimalPlaces = scalingAmountPicker.DecimalPlaces = rotationAmountPicker.DecimalPlaces = ADJUSTMENT_PICKER_NUM_DP;
            translationAmountPicker.Minimum       = MIN_TRANSLATION_ADJUSTMENT;
            translationAmountPicker.Maximum       = MAX_TRANSLATION_ADJUSTMENT;
            translationAmountPicker.Value         = DEFAULT_TRANSLATION_ADJUSTMENT;
            translationAmountPicker.Increment     = TRANSLATION_ADJUSTMENT_STEP;
            scalingAmountPicker.Minimum           = MIN_SCALING_ADJUSTMENT;
            scalingAmountPicker.Maximum           = MAX_SCALING_ADJUSTMENT;
            scalingAmountPicker.Value             = DEFAULT_SCALING_ADJUSTMENT;
            scalingAmountPicker.Increment         = SCALING_ADJUSTMENT_STEP;
            rotationAmountPicker.Minimum          = (decimal)MathUtils.RadToDeg((float)MIN_ROTATION_ADJUSTMENT);
            rotationAmountPicker.Maximum          = (decimal)MathUtils.RadToDeg((float)MAX_ROTATION_ADJUSTMENT);
            rotationAmountPicker.Value            = (decimal)MathUtils.RadToDeg((float)DEFAULT_ROTATION_ADJUSTMENT);
            rotationAmountPicker.Increment        = (decimal)MathUtils.RadToDeg((float)ROTATION_ADJUSTMENT_STEP);

            SetGOControlEnabledState(false);
            objectList.SelectedValueChanged += (sender, args) => UpdateSelectedObject();
            UpdateObjectList();

            bindButton.MouseClick         += (sender, args) => BindSelectedGO();
            simpleBindingCheck.MouseClick += (sender, args) => ChangeBindingSimplicity();
            cloneButton.MouseClick        += (sender, args) => CloneSelectedGO();
            deleteButton.MouseClick       += (sender, args) => DeleteSelectedGO();

            tfmBtn_trXNeg.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Translation, TransformAdjustmentAxis.X, true);
            tfmBtn_trXPos.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Translation, TransformAdjustmentAxis.X, false);
            tfmBtn_trYNeg.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Translation, TransformAdjustmentAxis.Y, true);
            tfmBtn_trYPos.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Translation, TransformAdjustmentAxis.Y, false);
            tfmBtn_trZNeg.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Translation, TransformAdjustmentAxis.Z, true);
            tfmBtn_trZPos.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Translation, TransformAdjustmentAxis.Z, false);

            tfmBtn_scXDec.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Scale, TransformAdjustmentAxis.X, true);
            tfmBtn_scXInc.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Scale, TransformAdjustmentAxis.X, false);
            tfmBtn_scYDec.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Scale, TransformAdjustmentAxis.Y, true);
            tfmBtn_scYInc.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Scale, TransformAdjustmentAxis.Y, false);
            tfmBtn_scZDec.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Scale, TransformAdjustmentAxis.Z, true);
            tfmBtn_scZInc.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Scale, TransformAdjustmentAxis.Z, false);

            tfmBtn_rotXAnt.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Rotation, TransformAdjustmentAxis.X, true);
            tfmBtn_rotXClo.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Rotation, TransformAdjustmentAxis.X, false);
            tfmBtn_rotYAnt.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Rotation, TransformAdjustmentAxis.Y, true);
            tfmBtn_rotYClo.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Rotation, TransformAdjustmentAxis.Y, false);
            tfmBtn_rotZAnt.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Rotation, TransformAdjustmentAxis.Z, true);
            tfmBtn_rotZClo.MouseClick += (_, __) => AdjustSelectedGOTransform(TransformAdjustmentType.Rotation, TransformAdjustmentAxis.Z, false);

            snapToCameraButton.MouseClick += (_, __) => SnapSelectedToCamera();
            moveCamToObjButton.MouseClick += (_, __) => MoveCameraToSelectedItem();

            FormClosing += (_, __) => objectList.SelectedIndex = -1;
        }
コード例 #2
0
        void okButton_MouseClick(object sender, MouseEventArgs e)
        {
            if (!IOUtils.IsValidFilePath(filenameTextBox.Text))
            {
                MessageBox.Show(this, "Invalid file name.");
                return;
            }
            if (titleTextBox.Text.IsNullOrWhiteSpace())
            {
                MessageBox.Show(this, "Invalid title.");
                return;
            }

            GameLevelDescription curLevelAsGameLevel = currentLevel as GameLevelDescription;

            try {
                if (curLevelAsGameLevel != null)
                {
                    curLevelAsGameLevel.LevelTimerGoldMs =
                        (int)MathUtils.Clamp(Int32.Parse(goldSecsTextBox.Text), 0, 300) * 1000
                        + (int)MathUtils.Clamp(Int32.Parse(goldHundsTextBox.Text), 0, 100) * 10;

                    curLevelAsGameLevel.LevelTimerSilverMs =
                        (int)MathUtils.Clamp(Int32.Parse(silverSecsTextBox.Text), 0, 300) * 1000
                        + (int)MathUtils.Clamp(Int32.Parse(silverHundsTextBox.Text), 0, 100) * 10;

                    curLevelAsGameLevel.LevelTimerBronzeMs =
                        (int)MathUtils.Clamp(Int32.Parse(bronzeSecsTextBox.Text), 0, 300) * 1000
                        + (int)MathUtils.Clamp(Int32.Parse(bronzeHundsTextBox.Text), 0, 100) * 10;

                    curLevelAsGameLevel.LevelTimerMaxMs =
                        (int)MathUtils.Clamp(Int32.Parse(maxSecsTextBox.Text), 0, 300) * 1000
                        + (int)MathUtils.Clamp(Int32.Parse(maxHundsTextBox.Text), 0, 100) * 10;

                    curLevelAsGameLevel.NumHops = (int)numHopsUpDown.Value;
                }
            }
            catch (FormatException ex) {
                MessageBox.Show(this, "Invalid value in one or more level timer text boxes." + Environment.NewLine + Environment.NewLine + ex.GetAllMessages(), "Can not apply changes!");
                return;
            }
            catch (OverflowException ex) {
                MessageBox.Show(this, "Invalid value in one or more level timer text boxes." + Environment.NewLine + Environment.NewLine + ex.GetAllMessages(), "Can not apply changes!");
                return;
            }
            finally {
                UpdateTimeTextBoxes();
            }
            commitChangesAction(gameLevelRadio.Checked, titleTextBox.Text, filenameTextBox.Text, skyboxButton.Text);
            Close();
        }
コード例 #3
0
        private void UpdateTimeTextBoxes()
        {
            GameLevelDescription curLevelAsGameLevel = currentLevel as GameLevelDescription;

            if (curLevelAsGameLevel != null)
            {
                goldSecsTextBox.Text  = (curLevelAsGameLevel.LevelTimerGoldMs / 1000).ToString("00");
                goldHundsTextBox.Text = ((curLevelAsGameLevel.LevelTimerGoldMs % 1000) / 10).ToString("00");

                silverSecsTextBox.Text  = (curLevelAsGameLevel.LevelTimerSilverMs / 1000).ToString("00");
                silverHundsTextBox.Text = ((curLevelAsGameLevel.LevelTimerSilverMs % 1000) / 10).ToString("00");

                bronzeSecsTextBox.Text  = (curLevelAsGameLevel.LevelTimerBronzeMs / 1000).ToString("00");
                bronzeHundsTextBox.Text = ((curLevelAsGameLevel.LevelTimerBronzeMs % 1000) / 10).ToString("00");

                maxSecsTextBox.Text  = (curLevelAsGameLevel.LevelTimerMaxMs / 1000).ToString("00");
                maxHundsTextBox.Text = ((curLevelAsGameLevel.LevelTimerMaxMs % 1000) / 10).ToString("00");

                numHopsUpDown.Value = curLevelAsGameLevel.NumHops;
            }
        }