Ejemplo n.º 1
0
        private void btnApplyScore_Click(object sender, EventArgs e)
        {
            ObjectiveXML objective = GetSelectedObjective();

            // Get string as integer
            uint score      = 0;
            bool validScore = uint.TryParse(txtBoxScore.Text, out score);

            // If not a valid score
            if (!validScore)
            {
                MessageBox.Show("This is not a valid score.  Please use numbers only.", // Message
                                "Invalid Score",                                        // Caption
                                MessageBoxButtons.OK,                                   // Buttons
                                MessageBoxIcon.Exclamation,                             // Icons
                                MessageBoxDefaultButton.Button1);                       // Default button

                return;
            }

            // Set local data to new name
            objective.mScore = (uint)score;

            // Deactivate objective score apply button
            btnApplyScore.Enabled = false;

            // Reset text box background color
            txtBoxScore.BackColor = SystemColors.Window;

            ObjectivesChanged();

            // Update controls
            UpdateControls();
        }
Ejemplo n.º 2
0
        // Assign ID based on max ID from scenario
        private void AssignID(ObjectiveXML objective)
        {
            // Bump current ID level
            SimGlobals.getSimMain().ObjectivesData.MaxObjectiveID++;

            // Assign ID
            objective.mID = SimGlobals.getSimMain().ObjectivesData.MaxObjectiveID;
        }
Ejemplo n.º 3
0
        // When a check box is changed
        private void CheckBoxChanged(CheckBox chkBox, string flag)
        {
            ObjectiveXML objective = GetSelectedObjective();

            if ((objective != null) && !mInternal)
            {
                objective.setFlag(chkBox.Checked, flag);
            }

            //ObjectivesChanged();
        }
Ejemplo n.º 4
0
        private void CountNeeded_ValueChanged(object sender, EventArgs e)
        {
            ObjectiveXML objective = GetSelectedObjective();

            if (objective == null)
            {
                return;
            }

            objective.mFinalCount = (int)CountNeeded.Value;

            ObjectivesChanged();
        }
Ejemplo n.º 5
0
        private void minTrackerIncrement_ValueChanged(object sender, EventArgs e)
        {
            ObjectiveXML objective = GetSelectedObjective();

            if (objective == null)
            {
                return;
            }

            objective.mMinTrackerIncrement = (int)minTrackerIncrement.Value;

            ObjectivesChanged();
        }
Ejemplo n.º 6
0
        private void trackerDuration_ValueChanged(object sender, EventArgs e)
        {
            ObjectiveXML objective = GetSelectedObjective();

            if (objective == null)
            {
                return;
            }

            objective.mTrackerDuration = (int)trackerDuration.Value;

            ObjectivesChanged();
        }
Ejemplo n.º 7
0
        // Create a new objective in the local data and add it to the list box
        private void btnNew_Click(object sender, EventArgs e)
        {
            ObjectiveXML newObjective = new ObjectiveXML();

            // Set default name
            int    offset = 1;
            string name   = FixupNamePrefix("Objective" + FormatCount(listBoxObjectives.Items.Count + offset), true);

            while (FindObjectiveByName(name) != null)
            {
                offset++;
                name = FixupNamePrefix("Objective" + FormatCount(listBoxObjectives.Items.Count + offset), true);
            }
            newObjective.mObjectiveName = name;

            // Set default flags
            newObjective.setFlag(true, "Required");
            newObjective.setFlag(true, "Player1");

            // Set default description
            // fixme - encode?
            newObjective.mDescription = "";

            // Set default hint
            newObjective.mHint = "";

            // Set the default score
            newObjective.mScore = 0;

            // Assign objective ID
            AssignID(newObjective);

            // Add to data
            SimGlobals.getSimMain().ObjectivesData.mObjectives.Add(newObjective);

            // Pause painting
            listBoxObjectives.BeginUpdate();

            // Add to list box
            listBoxObjectives.Items.Add(newObjective.mObjectiveName);

            // Assign list box selection to the new objective
            listBoxObjectives.SelectedIndex = listBoxObjectives.Items.IndexOf(newObjective.mObjectiveName);

            // Resume painting
            listBoxObjectives.EndUpdate();


            ObjectivesChanged();
        }
Ejemplo n.º 8
0
        private void btnApplyObjectiveName_Click(object sender, EventArgs e)
        {
            ObjectiveXML objective = GetSelectedObjective();

            // Get proper name prefix
            string nameFixup = FixupNamePrefix(txtBoxObjectiveName.Text, objective.hasFlag("Required"));

            // See if name already exists
            if (FindObjectiveByName(nameFixup) != null)
            {
                MessageBox.Show("This name already exists in the list.  Please use a different name.", // Message
                                "Duplicate Name",                                                      // Caption
                                MessageBoxButtons.OK,                                                  // Buttons
                                MessageBoxIcon.Exclamation,                                            // Icons
                                MessageBoxDefaultButton.Button1);                                      // Default button

                return;
            }

            // See if name contains a space character
            if (nameFixup.Contains(" "))
            {
                MessageBox.Show("Please do not use spaces in the name.", // Message
                                "Invalid Characters",                    // Caption
                                MessageBoxButtons.OK,                    // Buttons
                                MessageBoxIcon.Exclamation,              // Icons
                                MessageBoxDefaultButton.Button1);        // Default button

                return;
            }

            // Set internal change flag
            mInternal = true;

            // Set local data to new name
            objective.mObjectiveName = nameFixup;

            // Set text box to new name
            txtBoxObjectiveName.Text = nameFixup;

            // Set internal change flag
            mInternal = false;

            // Update list box with new name
            ReplaceListBoxObjective(nameFixup);


            ObjectivesChanged();
        }
Ejemplo n.º 9
0
        // Find objective data by name
        private ObjectiveXML FindObjectiveByName(string name)
        {
            ObjectiveXML retObjective = null;

            foreach (ObjectiveXML objective in SimGlobals.getSimMain().ObjectivesData.mObjectives)
            {
                if (objective.mObjectiveName == name)
                {
                    retObjective = objective;
                    break;
                }
            }

            return(retObjective);
        }
Ejemplo n.º 10
0
        private void chkBoxRequiredObjective_CheckedChanged(object sender, EventArgs e)
        {
            CheckBoxChanged((CheckBox)sender, "Required");

            ObjectiveXML objective = GetSelectedObjective();

            if ((objective != null) && !mInternal)
            {
                // Get proper name prefix
                string nameFixup = FixupNamePrefix(objective.mObjectiveName, chkBoxRequiredObjective.Checked);

                // Set local data to new name
                objective.mObjectiveName = nameFixup;

                // Set list box to new name
                ReplaceListBoxObjective(nameFixup);
            }
        }
Ejemplo n.º 11
0
        private void RetrieveObjectiveTrackerText()
        {
            ObjectiveXML objective = GetSelectedObjective();

            // Set internal change flag
            mInternal = true;

            // Set local data to new name
            if (IsStringID(mTxtTrackerStringID.Text))
            {
                string encodedLocStringID = EncodeLocStringID(mTxtTrackerStringID.Text);
                objective.mTrackerText = encodedLocStringID;
            }
            else
            {
                objective.mTrackerText = txtBoxObjectiveDescription.Text;
            }

            // Set internal change flag
            mInternal = false;
        }
Ejemplo n.º 12
0
        private void txtBoxObjectiveName_TextChanged(object sender, EventArgs e)
        {
            ObjectiveXML objective = GetSelectedObjective();

            if ((objective != null) && !mInternal && (objective.mObjectiveName != txtBoxObjectiveName.Text) && (txtBoxObjectiveName.Text.Length > 0))
            {
                // Activate objective name apply button
                btnApplyObjectiveName.Enabled = true;

                // Darken background of text box
                txtBoxObjectiveName.BackColor = SystemColors.ActiveBorder;
            }
            else
            {
                btnApplyObjectiveName.Enabled = false;

                // Reset text box background color
                txtBoxObjectiveName.BackColor = SystemColors.Window;
            }

            //ObjectivesChanged();
        }
Ejemplo n.º 13
0
        // Update all of the dependent controls
        private void UpdateControls()
        {
            if (listBoxObjectives.SelectedItem == null)
            {
                BlankControls();
                return;
            }

            // Grab local objective data
            ObjectiveXML objective = GetSelectedObjective();

            if (objective == null)
            {
                //Halwes - 12/1/2006 -  This is a problem handle it.
                BlankControls();
                return;
            }

            // Set internal changes flag
            mInternal = true;

            // Enable controls
            EnableControls(true);

            // Update objective name text box
            txtBoxObjectiveName.Text = listBoxObjectives.SelectedItem.ToString();

            // Disable objective name apply button and score apply button
            btnApplyObjectiveName.Enabled = false;
            btnApplyScore.Enabled         = false;

            // Update check boxes
            chkBoxPlayer1.Checked           = objective.hasFlag("Player1");
            chkBoxPlayer2.Checked           = objective.hasFlag("Player2");
            chkBoxPlayer3.Checked           = objective.hasFlag("Player3");
            chkBoxPlayer4.Checked           = objective.hasFlag("Player4");
            chkBoxPlayer5.Checked           = objective.hasFlag("Player5");
            chkBoxPlayer6.Checked           = objective.hasFlag("Player6");
            chkBoxRequiredObjective.Checked = objective.hasFlag("Required");

            // Update objective description text box
            int locID = DecodeLocStringID(objective.mDescription);

            // if (IsStringID(objective.mDescription))
            if ((locID >= 0) && IsStringID(locID))
            {
                SetObjectiveDescription(locID.ToString(), GetLocString(locID.ToString()));
            }
            else
            {
                if (objective.mHint.Length > 0)
                {
                    mLblStatusDescription.Text = "Please replace this with a Loc String ID !";
                }

                SetObjectiveDescription("", objective.mDescription);
            }

            // Update objective tracker text box
            locID = DecodeLocStringID(objective.mTrackerText);
            if ((locID > 0) && IsStringID(locID))
            {
                SetObjectiveTrackerText(locID.ToString(), GetLocString(locID.ToString()));
            }
            else
            {
                if (objective.mTrackerText.Length > 0)
                {
                    textTrackerText.Text = "Please replace this with a Loc String ID !";
                }

                SetObjectiveTrackerText("", objective.mTrackerText);
            }

            trackerDuration.Value     = objective.mTrackerDuration;
            minTrackerIncrement.Value = objective.mMinTrackerIncrement;

            // Update objective hint text box
            locID = DecodeLocStringID(objective.mHint);
            //if (IsStringID(objective.mHint))
            if ((locID > 0) && IsStringID(locID))
            {
                SetObjectiveHint(locID.ToString(), GetLocString(locID.ToString()));
            }
            else
            {
                if (objective.mHint.Length > 0)
                {
                    mLblStatusHint.Text = "Please replace this with a Loc String ID !";
                }

                SetObjectiveHint("", objective.mHint);
            }

            // Update score text box
            txtBoxScore.Text = objective.mScore.ToString();

            CountNeeded.Value = objective.mFinalCount;

            // Set internal changes flag
            mInternal = false;
        }