コード例 #1
0
 private void menuComment_Click(object sender, EventArgs e)
 {
     GetSelected();
     if (iSelectedSet >= 0)
     {   //If something selected
         InputBox uBox = new InputBox();//Use input box
         if (uBox.AskUser(uList.uLevelSets[iSelectedSet].sComment, "LevelSet comment", "Your comment:") == DialogResult.OK) //Ask user about new comment
         {   //If new comment confirmed
             uList.uLevelSets[iSelectedSet].sComment = uBox.GetResult();//Update comment
             uList.UpdateDisplayed(iSelectedSet);//Update displayed text (as comment changed)
             Enlist();//Update listbox
         }
     }
     return;
 }
コード例 #2
0
 private void menuAddDelimiter_Click(object sender, EventArgs e)
 {
     GetSelected();
     InputBox uBox = new InputBox();//Use input box
     if (uBox.AskUser("-", "Delimiter text", "Your text:") == DialogResult.OK) //Ask user about text
     {
         uList.AddDelimiter(uBox.GetResult(), iSelectedSet);
         Enlist();//Update listbox
     }
 }
コード例 #3
0
 ///<summary>User want to change background color</summary>
 private void ActionSetBackColor()
 {
     InputBox uRecName = new InputBox();
     LogSimpleLine(ActionID.ShowForm, "Ask; Background color");
     if (uRecName.AskUser(uSetting.iBackgroundColor.ToString("X").PadLeft(6, '0'), "Background Color", "Please specify background color in RRGGBB hexadecimal format:") != DialogResult.OK) //Promt user to write color in RRGGBB
         return;
     uSetting.iBackgroundColor = OQConvertTools.hex2int(uRecName.GetResult());
     uSetting.sBackgroundImageFile = "";//Clean image from settings to not use it
     if (uSetting.iBackgroundColor == -1)
         uSetting.iBackgroundColor = 0;//OQConvertTools.hex2int return -1 on errors
     LogSimpleLine(ActionID.ChangedBackground, "Set background color; " + uRecName.GetResult());
     UpdateBackground();//Recreate background according to settings
     RedrawAllScreen();
 }
コード例 #4
0
        ///<summary>If level completed - display messages and move to the next</summary>
        private void CheckLevelCompletition()
        {
            if (uGame.IsLevelCompleted(false))//Check internal flag of level
            {
                DialogResult uDR;//Object for asking user
                bool bAskRecordName = uSetting.bAskRecordName;//Get option of asking about record name
                //string sMessage, sTitle;

                LogSimpleLine(ActionID.LevelSolved, "Level solved; " + (uLevelSet.GetCurrentLevel() + 1).ToString() + "; " + uLevelSet.sFileName);
                NonModalMessage("Level " + (uLevelSet.GetCurrentLevel() + 1).ToString() + " completed");//"+1" - to numerate level from 1

                uGame.RecalcStats();//This recalc stats, as not all stats calculated automatically

                //Default name of record: player, stats, data-time
                uGame.uStats.sName = uSetting.sPlayerName + ", " + uGame.uStats.ToString() + ", " + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");

                //Build all message for box
                const string sTitle = "Congratulations";
                string sMessage = "You solve level " + uGame.sTitle + "!\r\n";
                sMessage += "Your solution stats is: ";
                sMessage += uGame.uStats.ToString() + ".\r\n";
                SolutionFlags uFlags = uGame.EstimateNewSolution(uGame);//Check new solution for rectodrs
                if ((uFlags & SolutionFlags.FirstSolution) != 0)
                {
                    //First solution of this level
                    if (!uSetting.bAskSavingFirstSolution)
                    {
                        uDR = DialogResult.Yes;
                        bAskRecordName = false;
                        goto lSilentSave;
                    }
                    sMessage += "This is first solution of this level!\r\n";
                }
                else if (uFlags == SolutionFlags.Nothing)
                {
                    //No records achived
                    sMessage += "- No new records achived.\r\n";
                }
                else
                {
                    //Improved one-two records
                    if ((uFlags & SolutionFlags.BestMoves) != 0)
                        sMessage += "* This is new best-moves solution!\r\n";
                    if ((uFlags & SolutionFlags.BestPushes) != 0)
                        sMessage += "* This is new best-pushes solution!\r\n";
                }
                sMessage += "Do you want to save your solution?";

                LogSimpleLine(ActionID.ShowDialog, "Ask; Save new solution");
                //Ask user
                uDR = MessageBox.Show(sMessage, sTitle, MessageBoxButtons.YesNoCancel, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
            lSilentSave:
                switch (uDR)
                {
                    case DialogResult.Yes://User answer "yes" - save solution and advance to next level

                        if (bAskRecordName)//if allowed by settings
                        {//Ask name for new record
                            InputBox uRecName = new InputBox();
                            LogSimpleLine(ActionID.ShowForm, "Ask; Record name; " + uGame.uStats.sName);
                            if (uRecName.AskUser(uGame.uStats.sName, "Save record", "Please set record name:") != DialogResult.OK)
                                break;
                            uGame.uStats.sName = uRecName.GetResult();
                        }
                        if (uLevelSet.SaveNewRecord(uGame) != FunctionResult.OK) //Try to save record
                        {//Some problem with saving record
                            LogSimpleLine(ActionID.ShowDialog, "Info; Record was not saved, keep current level");
                            MessageBox.Show("Record was not saved.\r\nKeep current level...", "ERROR");
                            break;
                        }
                        uLevelSetList.UpdateSolved(uLevelSet.GetNumOfSolved());//Update number of solved levels in current levelset
                        //if (uGame.SavePosition(sSolutionsDirectory + AutoNamePosition() + ".sol", uLevelSet.sFileName, uLevelSet.GetCurrentLevel(), uSetting.sPlayerName) != 0) //Try to save solution
                        if (SavePosition(sSolutionsDirectory + AutoNamePosition() + ".sol") != FunctionResult.OK) //Try to save solution
                        {//Some problem with saving solution
                            LogSimpleLine(ActionID.ShowDialog, "Info; Solution was not saved, keep current level");
                            MessageBox.Show("Solution was not saved.\r\nKeep current level...", "ERROR");
                            break;
                        }
                        //break;
                        goto lNextLevel;
                    case DialogResult.No://User answer "no" - do not save solution but advance to next level
                    lNextLevel:
                        //bHaveUnfinishedPosition = false;//Solution saved or ignored - anyway position in ignored
                        KillAutosavedPosition();//Solution saved or ignored - autosaved position should be killed
                        //ActionNextLevel();
                        ActionNextUnsolved();
                        break;
                    default: //User answer "cancel - keep this level and do not save anything
                        break;
                }
            }
        }
コード例 #5
0
        ///<summary>User want to save current position</summary>
        public void ActionSavePosition()
        {
            if (uGame.uStats.iMoves == 0)
            {
                LogSimpleLine(ActionID.ShowDialog, "Info; Position empty, nothing to save");
                MessageBox.Show("You are on level start, nothing to save");
                return;
            }
            InputBox uAskFileName = new InputBox();
            string sFileName = AutoNamePosition();

            //Ask user about position filename
            LogSimpleLine(ActionID.ShowForm, "Ask; File for save position");
            if (uAskFileName.AskUser(sFileName, "Save position", "Please input position filename:") == DialogResult.OK)
            {
                FunctionResult uRV;
                uGame.RecalcStats();//Recalc stats (some of them are not calculated automatically)
                sFileName = uAskFileName.GetResult() + ".pos";
                uGame.uStats.sName = uAskFileName.GetResult();
                //if (uGame.SavePosition(sSolutionsDirectory + sFileName, uLevelSet.sFileName, uLevelSet.GetCurrentLevel(), uSetting.sPlayerName) != 0)//Saving
                uRV = SavePosition(sSolutionsDirectory + sFileName);
                if (uRV != FunctionResult.OK)//Saving
                {
                    LogSimpleLine(ActionID.ShowDialog, "Error; Position was not saved!; " + sFileName + "; " + uRV);
                    MessageBox.Show("Position was not saved! " + uRV.ToString(), "ERROR");
                    return;
                }
                LogSimpleLine(ActionID.SavePosition, "Position saved; " + uGame.uStats.iMoves.ToString() + " moves; " + sFileName);
                NonModalMessage("Position saved");
            }
        }