Example #1
0
        public static void Startup()
        {
            SFML.Portable.Activate();

            SetStatus(Strings.Get("loadscreen", "loading"));

            FrmMenu.Default.Visible = true;

            Application.DoEvents();

            C_Types.CharSelection = new C_Types.CharSelRec[4];

            C_Types.Player = new C_Types.PlayerRec[Constants.MAX_PLAYERS + 1];

            for (var i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                C_Player.ClearPlayer(i);
            }

            C_AutoTiles.ClearAutotiles();

            //Housing
            C_Housing.House       = new C_Housing.HouseRec[C_Housing.MaxHouses + 1];
            C_Housing.HouseConfig = new C_Housing.HouseRec[C_Housing.MaxHouses + 1];

            //quests
            C_Quest.ClearQuests();

            //npc's
            C_DataBase.ClearNpcs();
            C_Maps.Map.Npc = new int[Constants.MAX_MAP_NPCS + 1];
            C_Maps.MapNpc  = new C_Types.MapNpcRec[Constants.MAX_MAP_NPCS + 1];
            for (var i = 0; i <= Constants.MAX_MAP_NPCS; i++)
            {
                for (var x = 0; x <= (int)Enums.VitalType.Count - 1; x++)
                {
                    C_Maps.MapNpc[(int)i].Vital = new int[(int)x + 1];
                }
            }

            C_Shops.ClearShops();

            C_DataBase.ClearAnimations();

            C_DataBase.ClearAnimInstances();

            C_Banks.ClearBank();

            C_Projectiles.MapProjectiles = new C_Projectiles.MapProjectileRec[C_Projectiles.MaxProjectiles + 1];
            C_Projectiles.Projectiles    = new C_Projectiles.ProjectileRec[C_Projectiles.MaxProjectiles + 1];

            C_Items.ClearItems();

            //craft
            C_Crafting.ClearRecipes();

            //party
            C_Parties.ClearParty();

            //pets
            C_Pets.ClearPets();

            C_Variables.GettingMap = true;
            C_Variables.VbQuote    = System.Convert.ToString((char)34);           // "

            // Update the form with the game's name before it's loaded
            FrmGame.Default.Text = C_Constants.GameName;

            SetStatus(Strings.Get("loadscreen", "options"));

            // load options
            if (File.Exists(Application.StartupPath + "\\Data\\Config.xml"))
            {
                C_DataBase.LoadOptions();
            }
            else
            {
                C_DataBase.CreateOptions();
            }

            // randomize rnd's seed
            VBMath.Randomize();

            SetStatus(Strings.Get("loadscreen", "network"));

            FrmMenu.Default.Text = C_Constants.GameName;

            // DX7 Master Object is already created, early binding
            SetStatus(Strings.Get("loadscreen", "graphics"));
            C_Maps.CheckTilesets();
            C_DataBase.CheckCharacters();
            C_DataBase.CheckPaperdolls();
            C_DataBase.CheckAnimations();
            C_Items.CheckItems();
            C_Resources.CheckResources();
            C_DataBase.CheckSkillIcons();
            C_DataBase.CheckFaces();
            C_DataBase.CheckFog();
            C_DataBase.CacheMusic();
            C_DataBase.CacheSound();
            C_DataBase.CheckEmotes();
            C_DataBase.CheckPanoramas();
            C_Housing.CheckFurniture();
            C_Projectiles.CheckProjectiles();
            C_DataBase.CheckParallax();

            C_Graphics.InitGraphics();

            // check if we have main-menu music
            if (C_Types.Options.Music == 1 && C_Types.Options.MenuMusic.Trim().Length > 0)
            {
                C_Sound.PlayMusic(C_Types.Options.MenuMusic.Trim());
                C_Sound.MusicPlayer.Volume = 100;
            }

            // Reset values
            C_Variables.Ping = -1;

            // set values for directional blocking arrows
            C_Variables.DirArrowX[1] = 12;             // up
            C_Variables.DirArrowY[1] = 0;

            C_Variables.DirArrowX[2] = 12;             // down
            C_Variables.DirArrowY[2] = 23;

            C_Variables.DirArrowX[3] = 0;             // left
            C_Variables.DirArrowY[3] = 12;

            C_Variables.DirArrowX[4] = 23;             // right
            C_Variables.DirArrowY[4] = 12;

            //set gui switches
            C_UpdateUI.HudVisible = true;

            SetStatus(Strings.Get("loadscreen", "starting"));
            Started = true;
            C_UpdateUI.Frmmenuvisible = true;
            C_UpdateUI.Pnlloadvisible = false;

            //C_UpdateUI.PnlInventoryVisible = true;

            C_NetworkConfig.InitNetwork();

            C_GameLogic.GameLoop();
        }
Example #2
0
        public static void UpdateUi()
        {
            if (ReloadFrmMain == true)
            {
                ReloadFrmMain = false;
            }

            if (C_Variables.UpdateNews == true)
            {
                FrmMenu.Default.lblNews.Text = C_Variables.News;
                FrmMenu.Default.Text         = C_Constants.GameName;
                FrmGame.Default.Text         = C_Constants.GameName;
                C_Variables.UpdateNews       = false;
            }

            if (PnlRegisterVisible != FrmMenu.Default.pnlRegister.Visible)
            {
                FrmMenu.Default.pnlRegister.Visible = PnlRegisterVisible;
                FrmMenu.Default.pnlRegister.BringToFront();
            }

            if (DrawChar == true)
            {
                FrmMenu.Default.DrawCharacter();
                DrawChar = false;
            }

            if (PnlCharCreateVisible != FrmMenu.Default.pnlNewChar.Visible)
            {
                FrmMenu.Default.pnlNewChar.Visible = PnlCharCreateVisible;
                FrmMenu.Default.pnlNewChar.BringToFront();
                DrawChar = true;
            }

            if (Lblnextcharleft != FrmMenu.Default.lblNextChar.Left)
            {
                FrmMenu.Default.lblNextChar.Left = Lblnextcharleft;
            }

            if (!ReferenceEquals(Cmbclass, null))
            {
                FrmMenu.Default.cmbClass.Items.Clear();

                for (var i = 1; i <= (Cmbclass.Length - 1); i++)
                {
                    FrmMenu.Default.cmbClass.Items.Add(Cmbclass[(int)i]);
                }

                FrmMenu.Default.cmbClass.SelectedIndex = 0;

                FrmMenu.Default.rdoMale.Checked = true;

                FrmMenu.Default.txtCharName.Focus();

                Cmbclass = null;
            }

            if (PnlLoginVisible != FrmMenu.Default.pnlLogin.Visible)
            {
                FrmMenu.Default.pnlLogin.Visible = PnlLoginVisible;
                if (PnlLoginVisible)
                {
                    FrmMenu.Default.txtLogin.Focus();
                }
            }

            if (PnlCreditsVisible != FrmMenu.Default.pnlCredits.Visible)
            {
                FrmMenu.Default.pnlCredits.Visible = PnlCreditsVisible;
            }

            if (Frmmenuvisible != FrmMenu.Default.Visible)
            {
                FrmMenu.Default.Visible = Frmmenuvisible;
            }

            if (DrawCharSelect)
            {
                FrmMenu.Default.DrawCharacterSelect();
                DrawCharSelect = false;
            }

            if (PnlCharSelectVisible != FrmMenu.Default.pnlCharSelect.Visible)
            {
                FrmMenu.Default.pnlCharSelect.Visible = PnlCharSelectVisible;
                if (PnlCharSelectVisible)
                {
                    DrawCharSelect = true;
                }
            }

            if (Frmmaingamevisible != FrmGame.Default.Visible)
            {
                FrmGame.Default.Visible = Frmmaingamevisible;
            }

            if (C_Crafting.InitCrafting == true)
            {
                C_Crafting.CraftingInit();
                C_Crafting.InitCrafting = false;
            }

            if (NeedToOpenShop == true)
            {
                C_GameLogic.OpenShop(NeedToOpenShopNum);
                NeedToOpenShop    = false;
                NeedToOpenShopNum = 0;
                PnlShopVisible    = true;
            }

            if (NeedToOpenBank == true)
            {
                C_Banks.InBank = System.Convert.ToInt32(true);
                PnlBankVisible = true;
                C_Banks.DrawBank();
                NeedToOpenBank = false;
            }

            if (NeedToOpenTrade == true)
            {
                C_Trade.InTrade = true;
                PnlTradeVisible = true;

                NeedToOpenTrade = false;
            }

            if (NeedtoCloseTrade == true)
            {
                C_Trade.InTrade = false;
                PnlTradeVisible = false;

                NeedtoCloseTrade = false;
            }

            if (NeedtoUpdateTrade == true)
            {
                C_Trade.DrawTrade();
                NeedtoUpdateTrade = false;
            }

            if (UpdateCharacterPanel == true)
            {
                UpdateCharacterPanel = false;
            }

            if (Pnlloadvisible != FrmMenu.Default.pnlLoad.Visible)
            {
                FrmMenu.Default.pnlLoad.Visible = Pnlloadvisible;
            }

            if (UpdateMapnames == true)
            {
                int x = 0;

                FrmAdmin.Default.lstMaps.Items.Clear();

                for (x = 1; x <= Constants.MAX_MAPS; x++)
                {
                    FrmAdmin.Default.lstMaps.Items.Add(x.ToString());
                    FrmAdmin.Default.lstMaps.Items[x - 1].SubItems.Add(C_Types.MapNames[x]);
                }

                UpdateMapnames = false;
            }

            if (Adminvisible == true)
            {
                FrmAdmin.Default.Visible = !FrmAdmin.Default.Visible;
                Adminvisible             = false;
            }

            if (C_Quest.UpdateQuestChat == true)
            {
                C_Variables.DialogMsg1 = "Quest: " + Microsoft.VisualBasic.Strings.Trim(C_Quest.Quest[C_Quest.QuestNum].Name);
                C_Variables.DialogMsg2 = C_Quest.QuestMessage;

                C_Variables.DialogType = C_Constants.DialogueTypeQuest;

                if (C_Quest.QuestNumForStart > 0 && C_Quest.QuestNumForStart <= C_Quest.MaxQuests)
                {
                    C_Quest.QuestAcceptTag = C_Quest.QuestNumForStart;
                }

                C_Variables.UpdateDialog = true;

                C_Quest.UpdateQuestChat = false;
            }

            if (C_Quest.UpdateQuestWindow == true)
            {
                C_Quest.LoadQuestlogBox();
                C_Quest.UpdateQuestWindow = false;
            }

            if (C_Variables.UpdateDialog == true)
            {
                if (C_Variables.DialogType == C_Constants.DialogueTypeBuyhome || C_Variables.DialogType == C_Constants.DialogueTypeVisit)                 //house offer & visit
                {
                    C_Variables.DialogButton1Text = "Accept";
                    C_Variables.DialogButton2Text = "Decline";
                    DialogPanelVisible            = true;
                }
                else if (C_Variables.DialogType == C_Constants.DialogueTypeParty || C_Variables.DialogType == C_Constants.DialogueTypeTrade)
                {
                    C_Variables.DialogButton1Text = "Accept";
                    C_Variables.DialogButton2Text = "Decline";
                    DialogPanelVisible            = true;
                }
                else if (C_Variables.DialogType == C_Constants.DialogueTypeQuest)
                {
                    C_Variables.DialogButton1Text = "Accept";
                    C_Variables.DialogButton2Text = "Ok";
                    if (C_Quest.QuestAcceptTag > 0)
                    {
                        C_Variables.DialogButton2Text = "Decline";
                    }
                    DialogPanelVisible = true;
                }

                C_Variables.UpdateDialog = false;
            }

            if (C_EventSystem.EventChat == true)
            {
                PnlEventChatVisible     = true;
                C_EventSystem.EventChat = false;
            }

            if (C_Variables.ShowRClick == true)
            {
                RClickname       = C_Types.Player[C_Variables.MyTarget].Name;
                RClickX          = C_Graphics.ConvertMapX(C_Variables.CurX * C_Constants.PicX);
                RClickY          = C_Graphics.ConvertMapY(C_Variables.CurY * C_Constants.PicY);
                PnlRClickVisible = true;

                C_Variables.ShowRClick = false;
            }

            if (InitMapEditor == true)
            {
                FrmEditor_MapEditor.Default.MapEditorInit();
                InitMapEditor = false;
            }

            if (InitMapProperties == true)
            {
                FrmEditor_MapEditor.Default.MapPropertiesInit();
                InitMapProperties = false;
            }

            if (C_EventSystem.InitEventEditorForm == true)
            {
                FrmEditor_Events.Default.InitEventEditorForm();

                // populate form
                // set the tabs
                if (FrmEditor_Events.Default.tabPages != null && FrmEditor_Events.Default.tabPages.TabPages != null)
                {
                    FrmEditor_Events.Default.tabPages.TabPages.Clear();

                    for (var i = 1; i <= C_EventSystem.TmpEvent.PageCount; i++)
                    {
                        FrmEditor_Events.Default.tabPages.TabPages.Add(Conversion.Str(i));
                    }
                    // items
                    FrmEditor_Events.Default.cmbHasItem.Items.Clear();
                    FrmEditor_Events.Default.cmbHasItem.Items.Add("None");
                    for (var i = 1; i <= Constants.MAX_ITEMS; i++)
                    {
                        FrmEditor_Events.Default.cmbHasItem.Items.Add(i + ": " + Microsoft.VisualBasic.Strings.Trim(Types.Item[(int)i].Name));
                    }
                    // variables
                    FrmEditor_Events.Default.cmbPlayerVar.Items.Clear();
                    FrmEditor_Events.Default.cmbPlayerVar.Items.Add("None");
                    for (var i = 1; i <= C_EventSystem.MaxVariables; i++)
                    {
                        FrmEditor_Events.Default.cmbPlayerVar.Items.Add(i + ". " + C_EventSystem.Variables[(int)i]);
                    }
                    // variables
                    FrmEditor_Events.Default.cmbPlayerSwitch.Items.Clear();
                    FrmEditor_Events.Default.cmbPlayerSwitch.Items.Add("None");
                    for (var i = 1; i <= C_EventSystem.MaxSwitches; i++)
                    {
                        FrmEditor_Events.Default.cmbPlayerSwitch.Items.Add(i + ". " + C_EventSystem.Switches[(int)i]);
                    }
                    // name
                    FrmEditor_Events.Default.txtName.Text = C_EventSystem.TmpEvent.Name;
                    // enable delete button
                    if (C_EventSystem.TmpEvent.PageCount > 1)
                    {
                        FrmEditor_Events.Default.btnDeletePage.Enabled = true;
                    }
                    else
                    {
                        FrmEditor_Events.Default.btnDeletePage.Enabled = false;
                    }
                    FrmEditor_Events.Default.btnPastePage.Enabled = false;
                    // Load page 1 to start off with
                    C_EventSystem.CurPageNum = 1;
                    C_EventSystem.EventEditorLoadPage(C_EventSystem.CurPageNum);

                    FrmEditor_Events.Default.nudShowTextFace.Maximum    = C_Graphics.NumFaces;
                    FrmEditor_Events.Default.nudShowChoicesFace.Maximum = C_Graphics.NumFaces;
                    // show the editor
                    FrmEditor_Events.Default.Show();

                    C_EventSystem.InitEventEditorForm = false;
                }
            }

            if (OptionsVisible == true)
            {
                // show in GUI
                if (C_Types.Options.Music == 1)
                {
                    FrmOptions.Default.optMOn.Checked = true;
                }
                else
                {
                    FrmOptions.Default.optMOff.Checked = true;
                }

                if (C_Types.Options.Music == 1)
                {
                    FrmOptions.Default.optSOn.Checked = true;
                }
                else
                {
                    FrmOptions.Default.optSOff.Checked = true;
                }

                FrmOptions.Default.lblVolume.Text   = "Volume: " + System.Convert.ToString(C_Types.Options.Volume);
                FrmOptions.Default.scrlVolume.Value = (int)C_Types.Options.Volume;

                FrmOptions.Default.cmbScreenSize.SelectedIndex = C_Types.Options.ScreenSize;

                if (C_Types.Options.VSync == 1)
                {
                    FrmOptions.Default.chkVSync.Checked = true;
                }
                else
                {
                    FrmOptions.Default.chkVSync.Checked = false;
                }

                if (C_Types.Options.UnlockFPS == 1)
                {
                    FrmOptions.Default.checkBox1.Checked = true;
                }
                else
                {
                    FrmOptions.Default.checkBox1.Checked = false;
                }

                if (C_Types.Options.ShowNpcBar == 1)
                {
                    FrmOptions.Default.chkNpcBars.Checked = true;
                }
                else
                {
                    FrmOptions.Default.chkNpcBars.Checked = false;
                }

                FrmOptions.Default.Visible = true;
                OptionsVisible             = false;
            }
        }
Example #3
0
 private void ChkKnownOnly_CheckedChanged(object sender, EventArgs e)
 {
     C_Crafting.CraftingInit();
 }