Esempio n. 1
0
        public SoundSystem()
        {
            var ret = FMOD.Result.OK;

            system = null;
            Program.WriteLine("SoundSystem: _ctor");
            if (!IniFile.GetValue("audio", "enabled", true))
            {
                return;
            }
            musicVolume = IniFile.GetValue("audio", "musicvolume", 100) / 100f;
            soundVolume = IniFile.GetValue("audio", "soundvolume", 100) / 100f;

            Program.Write("SoundSystem: trying to create FMOD system...");
            try
            {
                FMOD.Factory.CreateSystem(ref system);
            }
            catch (DllNotFoundException)
            {
                Program.WriteLine(" Library not found. Disabling sound.");
                return;
            }
            Program.WriteLine(" " + ret.ToString());
            if (ret != FMOD.Result.OK)
            {
                return;
            }
            Program.Write("SoundSystem: system.init...");
            ret = system.Initialize(8, FMOD.InitFlags.Normal, IntPtr.Zero);
            Program.WriteLine(" " + ret.ToString());
            if (ret != FMOD.Result.OK)
            {
                system = null;
                return;
            }
            music        = null;
            musicChannel = null;

            sounds = new Dictionary <string, Sound>();

            Program.WriteLine("SoundSystem: loading libraries...");
            musicLibrary = Mix.GetTokenTree("music.tml");
            soundLibrary = Mix.GetTokenTree("sound.tml");

            Program.WriteLine("SoundSystem: _ctor DONE");
            Program.WriteLine("Null report:");
            if (system == null)
            {
                Program.WriteLine(" * system");
            }
            if (music == null)
            {
                Program.WriteLine(" * music");
            }
            if (musicChannel == null)
            {
                Program.WriteLine(" * musicChannel");
            }
        }
Esempio n. 2
0
 public static string Length(float cm)
 {
     if (!IniFile.GetValue("misc", "imperial", false))
     {
         if (cm >= 100)
         {
             var m = Math.Floor(cm / 100);
             cm %= 100;
             if (cm > 0)
             {
                 return(m + "." + Math.Floor(cm) + "m");
             }
             else
             {
                 return(m + "m");
             }
         }
         if (Math.Floor(cm) != cm)
         {
             return(cm.ToString("F1") + "cm");
         }
         else
         {
             return(cm.ToString("F0") + "cm");
         }
     }
     else
     {
         var i = cm * 0.3937;
         if (i > 12)
         {
             var f = Math.Floor(i / 12);
             i %= 12;
             if (i > 0)
             {
                 return(f + "\x15E" + i.ToString("F0") + "\x15F");
             }
             else
             {
                 return(f + "\x15E");
             }
         }
         if (Math.Floor(i) != i)
         {
             return(i.ToString("F1") + "\x15F");
         }
         else
         {
             return(i.ToString("F0") + "\x15F");
         }
     }
 }
Esempio n. 3
0
        public void Update()
        {
            if (!Enabled)
            {
                return;
            }
            if (!string.IsNullOrEmpty(FadeTarget))
            {
                Fade();
            }
            system.Update();
#if DEBUG
            if (!IniFile.GetValue("audio", "debug", false))
            {
                return;
            }
            var musicchans = 0;
            var type       = FMOD.SoundType.Unknown;
            var format     = FMOD.SoundFormat.None;
            var channels   = 0;
            var bits       = 0;
            var volume     = 0f;
            var debug      = string.Empty;
            music.GetFormat(out type, out format, out channels, out bits);
            musicChannel.GetVolume(out volume);
            if (type == FMOD.SoundType.Mp3 | type == FMOD.SoundType.OggVorbis)
            {
                var ms  = 0u;
                var len = 0u;
                musicChannel.GetPosition(out ms, FMOD.TimeUnit.Milliseconds);
                music.GetLength(out len, FMOD.TimeUnit.Milliseconds);
                debug = string.Format("{0}ch {1}, {2} / {3}. Volume: {4:P0}", musicchans, type.ToString(), new TimeSpan(ms * 10000), new TimeSpan(len * 10000), volume);
            }
            else
            {
                var row      = 0u;
                var pattern  = 0u;
                var rows     = 0u;
                var patterns = 0u;
                music.GetMusicNumChannels(out musicchans);
                musicChannel.GetPosition(out row, FMOD.TimeUnit.ModRow);
                musicChannel.GetPosition(out pattern, FMOD.TimeUnit.ModPattern);
                music.GetLength(out rows, FMOD.TimeUnit.ModRow);
                music.GetLength(out patterns, FMOD.TimeUnit.ModPattern);
                debug = string.Format("{0}ch {1}, row {2}/{3}, pattern {4}/{5}. Volume: {6:P0}", musicchans, type.ToString(), row, rows, pattern, patterns, volume);
            }
            NoxicoGame.HostForm.Write(debug.PadRight(Program.Cols), System.Drawing.Color.Gray, System.Drawing.Color.Black, 0, 0);
#endif
        }
Esempio n. 4
0
        private static Bitmap backdrop;                   //, backWithPortrait;

        /// <summary>
        /// Don't see a Subscreen with multiple handlers often...
        /// </summary>
        public static void CharacterCreator()
        {
            if (Subscreens.FirstDraw)
            {
                //Start creating the world as we work...
                if (worldgen == null)                 //Conditional added by Mat.
                {
                    worldgen = new System.Threading.Thread(NoxicoGame.Me.CreateRealm);
                    worldgen.Start();
                }

                //Load all bonus traits.
                var traits     = new List <string>();
                var traitHelps = new List <string>();
                var traitsDoc  = Mix.GetTokenTree("bonustraits.tml");
                foreach (var trait in traitsDoc.Where(t => t.Name == "trait"))
                {
                    traits.Add(trait.GetToken("display").Text);
                    traitHelps.Add(trait.GetToken("description").Text);
                }
                //Define the help texts for the standard controls.
                controlHelps = new Dictionary <string, string>()
                {
                    { "back", i18n.GetString("cchelp_back") },
                    { "next", i18n.GetString("cchelp_next") },
                    { "play", Random.NextDouble() > 0.7 ? "FRUITY ANGELS MOLEST SHARKY" : "ENGAGE RIDLEY MOTHER F****R" },
                    { "name", i18n.GetString("cchelp_name") },
                    { "species", string.Empty },
                    { "sex", i18n.GetString("cchelp_sex") },
                    { "gid", i18n.GetString("cchelp_gid") },
                    { "pref", i18n.GetString("cchelp_pref") },
                    { "tutorial", i18n.GetString("cchelp_tutorial") },
                    { "easy", i18n.GetString("cchelp_easy") },
                    { "gift", traitHelps[0] },
                };

                var xScale = Program.Cols / 80f;
                var yScale = Program.Rows / 25f;

                //backdrop = Mix.GetBitmap("chargen.png");
                backdrop = new Bitmap(Program.Cols, Program.Rows * 2, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                var ccback   = Mix.GetBitmap("ccback.png");
                var ccpage   = Mix.GetBitmap("ccpage.png");
                var ccbars   = Mix.GetBitmap("ccbars.png");
                var pageLeft = Program.Cols - ccpage.Width - (int)(2 * yScale);
                var pageTop  = Program.Rows - (ccpage.Height / 2);
                using (var gfx = Graphics.FromImage(backdrop))
                {
                    gfx.Clear(Color.Black);
                    gfx.DrawImage(ccback, 0, 0, Program.Cols, Program.Rows * 2);
                    gfx.DrawImage(ccpage, pageLeft, pageTop, ccpage.Width, ccpage.Height);
                    var barsSrc = new System.Drawing.Rectangle(0, 3, ccbars.Width, 7);
                    var barsDst = new System.Drawing.Rectangle(0, 0, Program.Cols, 7);
                    gfx.DrawImage(ccbars, barsDst, barsSrc, GraphicsUnit.Pixel);
                    barsSrc = new System.Drawing.Rectangle(0, 0, ccbars.Width, 5);
                    barsDst = new System.Drawing.Rectangle(0, (Program.Rows * 2) - 5, Program.Cols, 5);
                    gfx.DrawImage(ccbars, barsDst, barsSrc, GraphicsUnit.Pixel);
                }

                //Build the interface.
                var      title       = "\xB4 " + i18n.GetString("cc_title") + " \xC3";
                var      bar         = new string('\xC4', 33);
                string[] sexoptions  = { i18n.GetString("Male"), i18n.GetString("Female"), i18n.GetString("Herm"), i18n.GetString("Neuter") };
                string[] prefoptions = { i18n.GetString("Male"), i18n.GetString("Female"), i18n.GetString("Either") };

                var labelL  = pageLeft + 5;
                var cntrlL  = labelL + 2;
                var header  = (pageTop / 2) + 3;
                var top     = header + 2;
                var buttons = (pageTop / 2) + 20;

                controls = new Dictionary <string, UIElement>()
                {
                    { "backdrop", new UIPNGBackground(backdrop) },                     //backWithPortrait) },
                    { "headerline", new UILabel(bar)
                      {
                          Left = labelL, Top = header, Foreground = Color.Black
                      } },
                    { "header", new UILabel(title)
                      {
                          Left = labelL + 17 - (title.Length() / 2), Top = header, Width = title.Length(), Foreground = Color.Black
                      } },
                    { "back", new UIButton(i18n.GetString("cc_back"), null)
                      {
                          Left = labelL, Top = buttons, Width = 10, Height = 1
                      } },
                    { "next", new UIButton(i18n.GetString("cc_next"), null)
                      {
                          Left = labelL + 23, Top = buttons, Width = 10, Height = 1
                      } },
                    { "wait", new UILabel(i18n.GetString("cc_wait"))
                      {
                          Left = labelL + 23, Top = buttons, Foreground = Color.Silver
                      } },
                    { "play", new UIButton(i18n.GetString("cc_play"), null)
                      {
                          Left = labelL + 23, Top = buttons, Width = 10, Height = 1, Hidden = true
                      } },

                    { "nameLabel", new UILabel(i18n.GetString("cc_name"))
                      {
                          Left = labelL, Top = top, Foreground = Color.Gray
                      } },
                    { "name", new UITextBox(string.Empty)
                      {
                          Left = cntrlL, Top = top + 1, Width = 24, Foreground = Color.Black, Background = Color.Transparent
                      } },
                    { "nameRandom", new UILabel(i18n.GetString("cc_random"))
                      {
                          Left = cntrlL + 2, Top = top + 1, Foreground = Color.Gray
                      } },
                    { "speciesLabel", new UILabel(i18n.GetString("cc_species"))
                      {
                          Left = labelL, Top = top + 3, Foreground = Color.Gray
                      } },
                    { "species", new UISingleList()
                      {
                          Left = cntrlL, Top = top + 4, Width = 26, Foreground = Color.Black, Background = Color.Transparent
                      } },
                    { "tutorial", new UIToggle(i18n.GetString("cc_tutorial"))
                      {
                          Left = labelL, Top = top + 6, Width = 24, Foreground = Color.Black, Background = Color.Transparent
                      } },
                    { "easy", new UIToggle(i18n.GetString("cc_easy"))
                      {
                          Left = labelL, Top = top + 7, Width = 24, Foreground = Color.Black, Background = Color.Transparent
                      } },

                    { "sexLabel", new UILabel(i18n.GetString("cc_sex"))
                      {
                          Left = labelL, Top = top, Foreground = Color.Gray
                      } },
                    { "sex", new UIRadioList(sexoptions)
                      {
                          Left = cntrlL, Top = top + 1, Width = 24, Foreground = Color.Black, Background = Color.Transparent
                      } },
                    { "gidLabel", new UILabel(i18n.GetString("cc_gid"))
                      {
                          Left = labelL, Top = top + 6, Foreground = Color.Gray
                      } },
                    { "gid", new UISingleList(string.Empty, null, sexoptions.ToList(), 0)
                      {
                          Left = cntrlL, Top = top + 7, Width = 26, Foreground = Color.Black, Background = Color.Transparent
                      } },
                    { "prefLabel", new UILabel(i18n.GetString("cc_pref"))
                      {
                          Left = labelL, Top = top + 9, Foreground = Color.Gray
                      } },
                    { "pref", new UISingleList(string.Empty, null, prefoptions.ToList(), 1)
                      {
                          Left = cntrlL, Top = top + 10, Width = 26, Foreground = Color.Black, Background = Color.Transparent
                      } },

                    { "giftLabel", new UILabel(i18n.GetString("cc_gift"))
                      {
                          Left = labelL, Top = top, Foreground = Color.Gray
                      } },
                    { "gift", new UIList(string.Empty, null, traits)
                      {
                          Left = cntrlL, Top = top + 1, Width = 30, Height = 24, Foreground = Color.Black, Background = Color.Transparent
                      } },

                    { "controlHelp", new UILabel(traitHelps[0])
                      {
                          Left = 1, Top = 1, Width = pageLeft - 2, Height = 4, Foreground = Color.White, Darken = true
                      } },
                    { "topHeader", new UILabel(i18n.GetString("cc_header"))
                      {
                          Left = 1, Top = 0, Foreground = Color.Silver
                      } },
                    { "helpLine", new UILabel(i18n.GetString("cc_footer"))
                      {
                          Left = 1, Top = Program.Rows - 1, Foreground = Color.Silver
                      } },
                };
                //Map the controls to pages.
                pages = new List <UIElement>[]
                {
                    new List <UIElement>()
                    {
                        controls["backdrop"], controls["headerline"], controls["header"], controls["topHeader"], controls["helpLine"],
                        controls["nameLabel"], controls["name"], controls["nameRandom"],
                        controls["speciesLabel"], controls["species"],
                        controls["tutorial"], controls["easy"],
                        controls["controlHelp"], controls["next"],
                    },
                    new List <UIElement>()
                    {
                        controls["backdrop"], controls["headerline"], controls["header"], controls["topHeader"], controls["helpLine"],
                        controls["sexLabel"], controls["sex"], controls["gidLabel"], controls["gid"], controls["prefLabel"], controls["pref"],
                        controls["controlHelp"], controls["back"], controls["next"],
                    },
                    new List <UIElement>(),                    //Placeholder, filled in on-demand from PlayableRace.ColorItems.
                    new List <UIElement>()
                    {
                        controls["backdrop"], controls["headerline"], controls["header"], controls["topHeader"], controls["helpLine"],
                        controls["giftLabel"], controls["gift"],
                        controls["controlHelp"], controls["back"], controls["wait"], controls["play"],
                    },
                };

                CollectPlayables();

                loadPage = new Action <int>(p =>
                {
                    UIManager.Elements.Clear();
                    UIManager.Elements.AddRange(pages[page]);
                    UIManager.Highlight = UIManager.Elements[5];                     //select whatever comes after helpLine.
                });

                //Called when changing species.
                loadColors = new Action <int>(i =>
                {
                    var species             = playables[i];
                    controlHelps["species"] = species.Bestiary;
                    pages[2].Clear();
                    pages[2].AddRange(new[] { controls["backdrop"], controls["headerline"], controls["header"], controls["topHeader"], controls["helpLine"] });
                    pages[2].AddRange(species.ColorItems.Values);
                    pages[2].AddRange(new[] { controls["controlHelp"], controls["back"], controls["next"] });
                });

                controls["back"].Enter = (s, e) => { page--; loadPage(page); UIManager.Draw(); };
                controls["next"].Enter = (s, e) => { page++; loadPage(page); UIManager.Draw(); };
                controls["play"].Enter = (s, e) =>
                {
                    var playerName = controls["name"].Text;
                    var sex        = ((UIRadioList)controls["sex"]).Value;
                    var gid        = ((UISingleList)controls["gid"]).Index;
                    var pref       = ((UISingleList)controls["pref"]).Index;
                    var species    = ((UISingleList)controls["species"]).Index;
                    var tutorial   = ((UIToggle)controls["tutorial"]).Checked;
                    var easy       = ((UIToggle)controls["easy"]).Checked;
                    var bonus      = ((UIList)controls["gift"]).Text;
                    var colorMap   = new Dictionary <string, string>();
                    foreach (var editable in playables[species].ColorItems)
                    {
                        if (editable.Key.StartsWith("lbl"))
                        {
                            continue;
                        }
                        var path  = editable.Key;
                        var value = ((UISingleList)editable.Value).Text;
                        colorMap.Add(path, value);
                    }
                    NoxicoGame.Me.CreatePlayerCharacter(playerName.Trim(), (Gender)(sex + 1), (Gender)(gid + 1), pref, playables[species].ID, colorMap, bonus);
                    if (tutorial)
                    {
                        NoxicoGame.Me.Player.Character.AddToken("tutorial");
                    }
                    if (easy)
                    {
                        NoxicoGame.Me.Player.Character.AddToken("easymode");
                    }
                    NoxicoGame.InGameTime = NoxicoGame.InGameTime.AddYears(Random.Next(0, 10));
                    NoxicoGame.InGameTime = NoxicoGame.InGameTime.AddDays(Random.Next(20, 340));
                    NoxicoGame.InGameTime = NoxicoGame.InGameTime.AddHours(Random.Next(10, 54));
                    NoxicoGame.Me.CurrentBoard.UpdateLightmap(NoxicoGame.Me.Player, true);
                    Subscreens.FirstDraw = true;
                    NoxicoGame.Immediate = true;

                    /*
                     #if DEBUG
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("orgasm_denial_ring");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("baseballbat");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("really_kinky_panties");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("timertest");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("clit_regenring");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("gExtractor");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("strapon_ovi");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("strapon");
                     #if FREETESTPOTIONS
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("foxite"); // ok
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("odd_nip"); // ok
                     * //NoxicoGame.Me.Player.Character.GetToken("items").AddToken("dogmorph"); no bodyplan
                     * //NoxicoGame.Me.Player.Character.GetToken("items").AddToken("bunnymorph"); no bodyplan
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("chaos_potion"); // ok
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("enhanced_chaos_potion"); // ok
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("demonite_potion");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("tentacle_potion");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("cock_potion");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("corrupted_cock_potion");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("neutralizer_potion");
                     * NoxicoGame.Me.Player.Character.GetToken("items").AddToken("spidermorph");
                     #endif
                     #endif
                     */
                    NoxicoGame.AddMessage(i18n.GetString("welcometonoxico"), Color.Yellow);
                    NoxicoGame.AddMessage(i18n.GetString("rememberhelp"));

                    //Story();
                };

                ((UISingleList)controls["species"]).Items.Clear();
                playables.ForEach(x => ((UISingleList)controls["species"]).Items.Add(x.Name.Titlecase()));
                ((UISingleList)controls["species"]).Index = 0;
                loadColors(0);
                ((UIRadioList)controls["sex"]).ItemsEnabled = playables[0].SexLocks;
                controls["species"].Change = (s, e) =>
                {
                    var speciesIndex = ((UISingleList)controls["species"]).Index;
                    loadColors(speciesIndex);
                    var playable = playables[speciesIndex];
                    controlHelps["species"]      = playable.Bestiary;
                    controls["controlHelp"].Text = playable.Bestiary.Wordwrap(controls["controlHelp"].Width);
                    var sexList = (UIRadioList)controls["sex"];
                    sexList.ItemsEnabled = playable.SexLocks;
                    if (!sexList.ItemsEnabled[sexList.Value])
                    {
                        //Uh-oh. Select the first non-disabled item.
                        for (var i = 0; i < sexList.ItemsEnabled.Length; i++)
                        {
                            if (sexList.ItemsEnabled[i])
                            {
                                sexList.Value = i;
                                break;
                            }
                        }
                    }
                    //redrawBackdrop(0);
                    UIManager.Draw();
                };
                controls["sex"].Change = (s, e) =>
                {
                    //redrawBackdrop(0);
                    UIManager.Draw();
                };
                controls["name"].Change = (s, e) =>
                {
                    controls["nameRandom"].Hidden = !controls["name"].Text.IsBlank();
                    UIManager.Draw();
                };
                controls["gift"].Change = (s, e) =>
                {
                    var giftIndex = ((UIList)controls["gift"]).Index;
                    controls["controlHelp"].Text = traitHelps[giftIndex].Wordwrap(controls["controlHelp"].Width);
                    controls["controlHelp"].Top  = controls["gift"].Top + giftIndex;
                    UIManager.Draw();
                };

                ((UIToggle)controls["tutorial"]).Checked = IniFile.GetValue("misc", "tutorial", true);
                ((UIToggle)controls["easy"]).Checked     = IniFile.GetValue("misc", "easymode", false);

                UIManager.Initialize();
                UIManager.HighlightChanged = (s, e) =>
                {
                    var c = controls.FirstOrDefault(x => x.Value == UIManager.Highlight);
                    if (c.Key != null && controlHelps.ContainsKey(c.Key))
                    {
                        controls["controlHelp"].Text = controlHelps[c.Key].Wordwrap(controls["controlHelp"].Width);
                        controls["controlHelp"].Top  = c.Value.Top;
                    }
                    else
                    {
                        controls["controlHelp"].Text = string.Empty;
                    }
                    UIManager.Draw();
                };
                loadPage(page);
                //redrawBackdrop(0);
                Subscreens.FirstDraw = false;
                Subscreens.Redraw    = true;
                UIManager.HighlightChanged(null, null);
                NoxicoGame.Sound.PlayMusic("set://Character Creation", false);

                NoxicoGame.InGame = false;
            }

            if (Subscreens.Redraw)
            {
                UIManager.Draw();
                Subscreens.Redraw = false;
            }

            if (WorldGenFinished)
            {
                WorldGenFinished        = false;
                controls["play"].Hidden = false;
                UIManager.Draw();
            }

            UIManager.CheckKeys();
        }
Esempio n. 5
0
        public override void Update()
        {
            base.Update();
            NoxicoGame.ContextMessage = i18n.GetString("context_interactmode");
            if (this.ParentBoard == null)
            {
                NoxicoGame.Mode = UserMode.Walkabout;
                return;
            }
            //this.ParentBoard.Draw(true);

            if (NoxicoGame.IsKeyDown(KeyBinding.Interact) || NoxicoGame.IsKeyDown(KeyBinding.Back) || Vista.Triggers == XInputButtons.B)
            {
                NoxicoGame.Mode = UserMode.Walkabout;
                NoxicoGame.ClearKeys();
                NoxicoGame.ContextMessage = string.Empty;
                Hide();
                return;
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.TabFocus) || Vista.Triggers == XInputButtons.RightShoulder)
            {
                NoxicoGame.ClearKeys();
                Tabstop++;
                if (Tabstop >= Tabstops.Count)
                {
                    Tabstop = 0;
                }
                XPosition = Tabstops[Tabstop].X;
                YPosition = Tabstops[Tabstop].Y;
                Point();
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.Accept) || Vista.Triggers == XInputButtons.A)
            {
                Subscreens.PreviousScreen.Clear();
                NoxicoGame.ClearKeys();
                var player = NoxicoGame.Me.Player;
#if DEBUG
                if (PointingAt == null)
                {
                    ActionList.Show("Debug?", this.XPosition - NoxicoGame.CameraX, this.YPosition - NoxicoGame.CameraY,
                                    new Dictionary <object, string>()
                    {
                        { "teleport", "Teleport" },
                        { "spawn", "Spawn character" },
                    },
                                    () =>
                    {
                        Hide();
                        if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                        {
                            NoxicoGame.Mode = UserMode.Walkabout;
                            Hide();
                            return;
                        }
                        switch (ActionList.Answer as string)
                        {
                        case "teleport":
                            player.XPosition = this.XPosition;
                            player.YPosition = this.YPosition;
                            ParentBoard.AimCamera();
                            ParentBoard.Redraw();
                            NoxicoGame.Mode = UserMode.Aiming;
                            Point();
                            return;

                        case "spawn":
                            var spawnOptions = new Dictionary <object, string>();
                            foreach (var bp in Character.Bodyplans)
                            {
                                spawnOptions[bp.Text] = bp.Text;
                            }
                            var uniques = Mix.GetTokenTree("uniques.tml", true);
                            foreach (var bp in uniques)
                            {
                                spawnOptions['!' + bp.Text] = bp.Text;
                            }
                            ActionList.Show("Debug?", this.XPosition - NoxicoGame.CameraX, this.YPosition - NoxicoGame.CameraY, spawnOptions,
                                            () =>
                            {
                                if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                                {
                                    NoxicoGame.Mode = UserMode.Aiming;
                                    Point();
                                    return;
                                }
                                Character newChar = null;
                                if (ActionList.Answer is string && ((string)ActionList.Answer).StartsWith('!'))
                                {
                                    newChar = Character.GetUnique(((string)ActionList.Answer).Substring(1));
                                }
                                else
                                {
                                    newChar = Character.Generate((string)ActionList.Answer, Gender.RollDice);
                                }
                                var newBoardChar = new BoardChar(newChar)
                                {
                                    XPosition   = this.XPosition,
                                    YPosition   = this.YPosition,
                                    ParentBoard = this.ParentBoard
                                };
                                newBoardChar.AdjustView();
                                ParentBoard.EntitiesToAdd.Add(newBoardChar);
                                ParentBoard.Redraw();
                                NoxicoGame.Mode = UserMode.Walkabout;
                                Hide();
                                return;
                            }
                                            );
                            break;
                        }
                    }
                                    );
                }
#endif
                if (PointingAt != null)
                {
                    LastTarget = PointingAt;
                    var distance = player.DistanceFrom(PointingAt);
                    var canSee   = player.CanSee(PointingAt);

                    var options     = new Dictionary <object, string>();
                    var description = "something";

                    options["look"] = i18n.GetString("action_lookatit");

                    if (PointingAt is Player)
                    {
                        description     = i18n.Format("action_descyou", player.Character.Name);
                        options["look"] = i18n.GetString("action_lookatyou");
                        if (player.Character.GetStat("excitement") >= 30)
                        {
                            options["f**k"] = i18n.GetString("action_masturbate");
                        }

                        if (player.Character.HasToken("copier") && player.Character.GetToken("copier").Value == 1)
                        {
                            if (player.Character.Path("copier/backup") != null || player.Character.Path("copier/full") == null)
                            {
                                options["revert"] = i18n.GetString("action_revert");
                            }
                        }
                    }
                    else if (PointingAt is DroppedItem)
                    {
                        var drop  = PointingAt as DroppedItem;
                        var item  = drop.Item;
                        var token = drop.Token;
                        description = item.ToString(token);
                        if (distance <= 1)
                        {
                            options["take"] = i18n.GetString("action_pickup");
                        }
                    }
                    else if (PointingAt is Container)
                    {
                        var container = PointingAt as Container;
                        description = container.Name ?? "container";
                    }
                    else if (PointingAt is Clutter)
                    {
                        var clutter = PointingAt as Clutter;
                        description = clutter.Name ?? "something";
                        if (clutter.ID == "craftstation")
                        {
                            options["craft"] = i18n.GetString("action_craft");
                        }
                    }
                    else if (PointingAt is BoardChar)
                    {
                        var boardChar = PointingAt as BoardChar;
                        description     = boardChar.Character.GetKnownName(true);
                        options["look"] = i18n.Format("action_lookathim", boardChar.Character.HimHerIt(true));

                        if (canSee && distance <= 2 && !boardChar.Character.HasToken("beast") && !boardChar.Character.HasToken("sleeping"))
                        {
                            options["talk"] = i18n.Format("action_talktohim", boardChar.Character.HimHerIt(true));
                            if (boardChar.Character.Path("role/vendor") != null && boardChar.Character.Path("role/vendor/class").Text != "carpenter")
                            {
                                options["trade"] = i18n.Format("action_trade", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && player.Character.GetStat("excitement") >= 30 && distance <= 1)
                        {
                            var mayFuck  = boardChar.Character.HasToken("willing");
                            var willRape = boardChar.Character.HasToken("helpless");

                            if (!IniFile.GetValue("misc", "allowrape", false) && willRape)
                            {
                                mayFuck = false;
                            }
                            //but DO allow it if they're helpless but willing
                            if (boardChar.Character.HasToken("willing") && willRape)
                            {
                                mayFuck  = true;
                                willRape = false;
                            }
                            if (boardChar.Character.HasToken("beast"))
                            {
                                mayFuck = false;
                            }

                            if (mayFuck)
                            {
                                options["f**k"] = i18n.Format(willRape ? "action_rapehim" : "action_fuckhim", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && !boardChar.Character.HasToken("beast") && player.Character.HasToken("copier") && player.Character.Path("copier/timeout") == null)
                        {
                            //if (player.Character.UpdateCopier())
                            if (player.Character.HasToken("fullCopy") || player.Character.HasToken("sexCopy"))
                            {
                                options["copy"] = i18n.Format("action_copyhim", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && player.Character.CanShoot() != null && player.ParentBoard.HasToken("combat"))
                        {
                            options["shoot"] = i18n.Format("action_shoothim", boardChar.Character.HimHerIt(true));
                        }
                    }

#if DEBUG
                    if (PointingAt is BoardChar)
                    {
                        options["mutate"] = "(debug) Random mutate";
                    }
                    if (PointingAt is BoardChar)
                    {
                        options["turbomutate"] = "(debug) Apply LOTS of mutations!";
                    }
#endif

                    ActionList.Show(description, PointingAt.XPosition - NoxicoGame.CameraX, PointingAt.YPosition - NoxicoGame.CameraY, options,
                                    () =>
                    {
                        Hide();
                        if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                        {
                            //NoxicoGame.Messages.Add("[Aim message]");
                            NoxicoGame.Mode = UserMode.Aiming;
                            Point();
                            return;
                        }
                        switch (ActionList.Answer as string)
                        {
                        case "look":
                            if (PointingAt is DroppedItem)
                            {
                                var drop  = PointingAt as DroppedItem;
                                var item  = drop.Item;
                                var token = drop.Token;
                                var text  = (item.HasToken("description") && !token.HasToken("unidentified") ? item.GetToken("description").Text : i18n.Format("thisis_x", item.ToString(token))).Trim();
                                MessageBox.Notice(text, true);
                            }
                            else if (PointingAt is Clutter && !((Clutter)PointingAt).Description.IsBlank())
                            {
                                MessageBox.Notice(((Clutter)PointingAt).Description.Trim(), true, ((Clutter)PointingAt).Name ?? "something");
                            }
                            else if (PointingAt is Container)
                            {
                                MessageBox.Notice(((Container)PointingAt).Description.Trim(), true, ((Container)PointingAt).Name ?? "container");
                            }
                            else if (PointingAt is BoardChar)
                            {
                                if (((BoardChar)PointingAt).Character.HasToken("beast"))
                                {
                                    MessageBox.Notice(((BoardChar)PointingAt).Character.LookAt(PointingAt), true, ((BoardChar)PointingAt).Character.GetKnownName(true));
                                }
                                else
                                {
                                    TextScroller.LookAt((BoardChar)PointingAt);
                                }
                            }
                            break;

                        case "talk":
                            if (PointingAt is Player)
                            {
                                //if (Culture.CheckSummoningDay()) return;
                                if (player.Character.Path("mind").Value >= 10)
                                {
                                    MessageBox.Notice(i18n.GetString("talkingotyourself"), true);
                                }
                                else
                                {
                                    MessageBox.Notice(i18n.GetString("talkingtoyourself_nutso"), true);
                                }
                            }
                            else if (PointingAt is BoardChar)
                            {
                                var boardChar = PointingAt as BoardChar;
                                if (boardChar.Character.HasToken("hostile") && !boardChar.Character.HasToken("helpless"))
                                {
                                    MessageBox.Notice(i18n.Format("nothingtosay", boardChar.Character.GetKnownName(false, false, true, true)), true);
                                }
                                else
                                {
                                    SceneSystem.Engage(player.Character, boardChar.Character);
                                }
                            }
                            break;

                        case "trade":
                            ContainerMan.Setup(((BoardChar)PointingAt).Character);
                            break;

                        case "f**k":
                            if (PointingAt is BoardChar)
                            {
                                SexManager.Engage(player.Character, ((BoardChar)PointingAt).Character);
                            }
                            break;

                        case "shoot":
                            player.AimShot(PointingAt);
                            break;

                        case "copy":
                            player.Character.Copy(((BoardChar)PointingAt).Character);
                            player.AdjustView();
                            //NoxicoGame.AddMessage(i18n.Format((player.Character.Path("copier/full") == null) ? "youimitate_x" : "become_x", ((BoardChar)PointingAt).Character.GetKnownName(false, false, true)));
                            NoxicoGame.AddMessage(i18n.Format(player.Character.HasToken("fullCopy") ? "x_becomes_y" : "x_imitates_y").Viewpoint(player.Character, ((BoardChar)PointingAt).Character));
                            player.Energy -= 2000;
                            break;

                        case "revert":
                            player.Character.Copy(null);
                            player.AdjustView();
                            NoxicoGame.AddMessage(i18n.GetString((player.Character.HasToken("fullCopy")) ? "youmelt" : "yourevert"));
                            player.Energy -= 1000;
                            break;

                        case "take":
                            if (PointingAt is DroppedItem)
                            {
                                var drop  = PointingAt as DroppedItem;
                                var item  = drop.Item;
                                var token = drop.Token;
                                drop.Take(player.Character, ParentBoard);
                                player.Energy -= 1000;
                                NoxicoGame.AddMessage(i18n.Format("youpickup_x", item.ToString(token, true)), drop.ForegroundColor);
                                NoxicoGame.Sound.PlaySound("set://GetItem");
                                ParentBoard.Redraw();
                            }
                            break;

                        case "craft":
                            Crafting.Open(player.Character);
                            break;

#if DEBUG
                        case "edit":
                            TokenCarrier tc = null;
                            if (PointingAt is DroppedItem)
                            {
                                tc = ((DroppedItem)PointingAt).Token;
                            }
                            else if (PointingAt is BoardChar)
                            {
                                tc = ((BoardChar)PointingAt).Character;
                            }

                            NoxicoGame.HostForm.Write("TOKEN EDIT ENGAGED. Waiting for editor process to exit.", Color.Black, Color.White, 0, 0);
                            NoxicoGame.HostForm.Draw();
                            ((MainForm)NoxicoGame.HostForm).timer.Enabled = false;
                            var dump = "-- WARNING! Many things may cause strange behavior or crashes. WATCH YOUR F*****G STEP.\r\n" + tc.DumpTokens(tc.Tokens, 0);
                            var temp = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString() + ".txt");
                            File.WriteAllText(temp, dump);
                            var process = System.Diagnostics.Process.Start(temp);
                            process.WaitForExit();
                            var newDump = File.ReadAllText(temp);
                            File.Delete(temp);
                            ((MainForm)NoxicoGame.HostForm).timer.Enabled = true;
                            ParentBoard.Redraw();
                            if (newDump == dump)
                            {
                                break;
                            }
                            tc.Tokenize(newDump);
                            ((BoardChar)PointingAt).AdjustView();
                            ((BoardChar)PointingAt).Character.RecalculateStatBonuses();
                            ((BoardChar)PointingAt).Character.CheckHasteSlow();
                            break;

                        case "mutate":
                            var result = ((BoardChar)PointingAt).Character.Mutate(1, 30);
                            NoxicoGame.AddMessage(result);
                            break;

                        case "turbomutate":
                            result = ((BoardChar)PointingAt).Character.Mutate(2500, 30);
                            NoxicoGame.AddMessage(result);
                            break;
#endif

                        default:
                            MessageBox.Notice("Unknown action handler \"" + ActionList.Answer.ToString() + "\".", true);
                            break;
                        }
                    }
                                    );             //	true, true);
                    return;
                }
                else
                {
                    /*
                     * var tSD = this.ParentBoard.GetDescription(YPosition, XPosition);
                     * if (!string.IsNullOrWhiteSpace(tSD))
                     * {
                     *      PointingAt = null;
                     *      MessageBox.ScriptPauseHandler = () =>
                     *      {
                     *              NoxicoGame.Mode = UserMode.Aiming;
                     *              Point();
                     *      };
                     *      MessageBox.Notice(tSD, true);
                     *      return;
                     * }
                     */
                }
            }

#if DEBUG
            if (NoxicoGame.KeyMap[Keys.D])
            {
                NoxicoGame.ClearKeys();
                if (PointingAt != null && PointingAt is BoardChar)
                {
                    ((BoardChar)PointingAt).Character.CreateInfoDump();
                    NoxicoGame.AddMessage("Info for " + ((BoardChar)PointingAt).Character.GetKnownName(true, true, true) + " dumped.", Color.Red);
                }
            }
#endif

            if (NoxicoGame.IsKeyDown(KeyBinding.Left) || Vista.DPad == XInputButtons.Left)
            {
                this.Move(Direction.West);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Right) || Vista.DPad == XInputButtons.Right)
            {
                this.Move(Direction.East);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Up) || Vista.DPad == XInputButtons.Up)
            {
                this.Move(Direction.North);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Down) || Vista.DPad == XInputButtons.Down)
            {
                this.Move(Direction.South);
            }
        }
Esempio n. 6
0
        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            NoxicoGame.KeyMap[e.KeyCode] = false;
            NoxicoGame.KeyTrg[e.KeyCode] = true;
            if (numpad.ContainsKey(e.KeyCode))
            {
                NoxicoGame.KeyMap[numpad[e.KeyCode]] = false;
                NoxicoGame.KeyTrg[numpad[e.KeyCode]] = true;
            }
            if (e.Modifiers == Keys.Shift)
            {
                NoxicoGame.Modifiers[0] = false;
            }

            if (e.KeyCode == (Keys)NoxicoGame.KeyBindings[KeyBinding.Screenshot])
            {
                if (e.Modifiers == Keys.Shift)
                {
                    using (var dumpFile = new StreamWriter("lol.txt", false, System.Text.Encoding.GetEncoding(437)))
                    {
                        for (int row = 0; row < Program.Rows; row++)
                        {
                            for (int col = 0; col < Program.Cols; col++)
                            {
                                dumpFile.Write(NoxicoGame.IngameTo437[image[col, row].Character]);
                            }
                            dumpFile.WriteLine();
                        }
                    }
                    using (var dumpFile = new StreamWriter("lol.html"))
                    {
                        dumpFile.WriteLine("<!DOCTYPE html><html><head>");
                        dumpFile.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html; CHARSET=utf-8\" />");
                        dumpFile.WriteLine("</head><body>");
                        dumpFile.WriteLine("<table style=\"font-family: Unifont, monospace\" cellspacing=0 cellpadding=0>");
                        for (int row = 0; row < Program.Rows; row++)
                        {
                            dumpFile.Write("<tr>");
                            for (int col = 0; col < Program.Cols; col++)
                            {
                                var ch = string.Format("&#x{0:X};", (int)NoxicoGame.IngameToUnicode[image[col, row].Character]);
                                if (ch == "&#x20;")
                                {
                                    ch = "&nbsp;";
                                }
                                dumpFile.Write("<td style=\"background:{1};color:{2}\">{0}</td>", ch, image[col, row].Background.ToHex(), image[col, row].Foreground.ToHex());
                            }
                            dumpFile.WriteLine("</tr>");
                        }
                        dumpFile.WriteLine("</table>");
                        dumpFile.WriteLine("</body></html>");
                    }
                    return;
                }

                var shotDir = IniFile.GetValue("misc", "shotpath", "screenshots");
                if (shotDir.StartsWith('$'))
                {
                    shotDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + shotDir.Substring(1);
                }

                if (!Directory.Exists(shotDir))
                {
                    Directory.CreateDirectory(shotDir);
                }
                int i = 1;
                while (File.Exists(Path.Combine(shotDir, "screenshot" + i.ToString("000") + ".png")))
                {
                    i++;
                }
                backBuffer.Save(Path.Combine(shotDir, "screenshot" + i.ToString("000") + ".png"), ImageFormat.Png);
                Program.WriteLine("Screenshot saved.");
            }
            if (e.KeyValue == 191)
            {
                NoxicoGame.KeyMap[Keys.L] = false;
            }

            if (e.KeyCode == Keys.R && e.Control)
            {
                NoxicoGame.KeyMap[Keys.R] = false;
                for (int row = 0; row < Program.Rows; row++)
                {
                    for (int col = 0; col < Program.Cols; col++)
                    {
                        previousImage[col, row].Character = '\uFFFE';
                    }
                }
            }

            if (e.KeyCode == Keys.A && e.Control && NoxicoGame.Mode == UserMode.Walkabout)
            {
                NoxicoGame.KeyMap[Keys.A] = false;
                NoxicoGame.ShowMessageLog();
            }

#if DEBUG
            if (e.KeyCode == Keys.E && e.Control && NoxicoGame.Mode == UserMode.Walkabout)
            {
                (new Editor()).LoadBoard(Noxico.CurrentBoard);
            }
#endif
        }
Esempio n. 7
0
        public void RestartGraphics(bool full)
        {
            pngFont = IniFile.GetValue("misc", "font", "8x16-bold");
            if (!Mix.FileExists("fonts\\" + pngFont + ".png"))
            {
                pngFont = "8x16-bold";
                if (!Mix.FileExists("fonts\\" + pngFont + ".png"))
                {
                    SystemMessageBox.Show(this, "Could not find font bitmaps. Please redownload the game.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Close();
                    return;
                }
            }
            var fontBitmap = Mix.GetBitmap("fonts\\" + pngFont + ".png");

            cellWidth  = fontBitmap.Width / 32;
            cellHeight = fontBitmap.Height / 32;

            IsSquare = cellWidth == cellHeight;

            Program.Cols = IniFile.GetValue("misc", "screencols", Program.Cols);
            Program.Rows = IniFile.GetValue("misc", "screenrows", Program.Rows);
            if (full)
            {
                image         = new Cell[Program.Cols, Program.Rows];
                previousImage = new Cell[Program.Cols, Program.Rows];
            }

            CachePNGFont(fontBitmap);

            fourThirtySeven = IniFile.GetValue("misc", "437", false);
            youtube         = IniFile.GetValue("misc", "youtube", false);
            ClientSize      = new Size(Program.Cols * cellWidth, Program.Rows * cellHeight);
            if (youtube)
            {
                //Find nearest YT size
                var eW = Program.Cols * cellWidth;
                var eH = Program.Rows * cellHeight;
                if (eW <= 854 || eH <= 480)
                {
                    ClientSize = new Size(854, 480);
                }
                else if (eW <= 1280 || eH <= 720)
                {
                    ClientSize = new Size(1280, 720);
                }
                else
                {
                    ClientSize = new Size(1920, 1080);
                }

                var prime = Screen.FromRectangle(ClientRectangle).Bounds;
                if (ClientSize.Width == prime.Width && ClientSize.Height == prime.Height)
                {
                    FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                    Left            = Top = 0;
                }
                else
                {
                    FormBorderStyle = IniFile.GetValue("misc", "border", true) ? System.Windows.Forms.FormBorderStyle.FixedSingle : System.Windows.Forms.FormBorderStyle.None;
                }
                youtubeRect = new System.Drawing.Rectangle((ClientSize.Width / 2) - (eW / 2), (ClientSize.Height / 2) - (eH / 2), eW, eH);
            }
            else
            {
                FormBorderStyle = IniFile.GetValue("misc", "border", true) ? System.Windows.Forms.FormBorderStyle.FixedSingle : System.Windows.Forms.FormBorderStyle.None;
            }

            Show();
            Refresh();

            backBuffer   = new Bitmap(Program.Cols * cellWidth, Program.Rows * cellHeight, PixelFormat.Format24bppRgb);
            scrollBuffer = new Bitmap(Program.Cols * cellWidth, Program.Rows * cellHeight, PixelFormat.Format24bppRgb);
            for (int row = 0; row < Program.Rows; row++)
            {
                for (int col = 0; col < Program.Cols; col++)
                {
                    previousImage[col, row].Character = '\uFFFE';
                }
            }
        }
Esempio n. 8
0
        public MainForm()
        {
#if !DEBUG
            try
#endif
            {
                this.Text            = "Noxico";
                this.BackColor       = System.Drawing.Color.Black;
                this.DoubleBuffered  = true;
                this.FormBorderStyle = FormBorderStyle.FixedSingle;
                this.MaximizeBox     = false;             //it's about time, too!
                this.FormClosing    += new FormClosingEventHandler(this.Form1_FormClosing);
                this.KeyDown        += new KeyEventHandler(this.Form1_KeyDown);
                this.KeyPress       += new KeyPressEventHandler(this.Form1_KeyPress);
                this.KeyUp          += new KeyEventHandler(this.Form1_KeyUp);
                this.Icon            = global::Noxico.Properties.Resources.app;
                this.ClientSize      = new Size(Program.Cols * cellWidth, Program.Rows * cellHeight);
                this.Controls.Add(new Label()
                {
                    Text      = "Loading...",
                    AutoSize  = true,
                    Font      = new System.Drawing.Font("Arial", 24, FontStyle.Bold | FontStyle.Italic),
                    ForeColor = System.Drawing.Color.White,
                    Visible   = true,
                    Location  = new System.Drawing.Point(16, 16)
                });

                foreach (var reqDll in new[] { "Neo.Lua.dll" })
                {
                    if (!File.Exists(reqDll))
                    {
                        throw new FileNotFoundException("Required DLL " + reqDll + " is missing.");
                    }
                }

                try
                {
                    Mix.Initialize("Noxico");
                }
                catch (UnauthorizedAccessException)
                {
                    if (!UacHelper.IsProcessElevated)
                    {
                        var proc = new System.Diagnostics.ProcessStartInfo();
                        proc.UseShellExecute  = true;
                        proc.WorkingDirectory = Environment.CurrentDirectory;
                        proc.FileName         = Application.ExecutablePath;
                        proc.Verb             = "runas";
                        try
                        {
                            System.Diagnostics.Process.Start(proc);
                        }
                        catch
                        {
                        }
                    }
                    Close();
                    return;
                }

                if (!Mix.FileExists("credits.txt"))
                {
                    SystemMessageBox.Show(this, "Could not find game data. Please redownload the game.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Close();
                    return;
                }

                var portable = false;
                IniPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "noxico.ini");
                if (File.Exists("portable"))
                {
                    portable = true;
                    var oldIniPath = IniPath;
                    IniPath = "noxico.ini";
                    Program.CanWrite();

                    /*
                     * if (!Program.CanWrite())
                     * {
                     *      var response = SystemMessageBox.Show(this, "Trying to start in portable mode, but from a protected location. Use non-portable mode?" + Environment.NewLine + "Selecting \"no\" may cause errors.", Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                     *      if (response == DialogResult.Cancel)
                     *      {
                     *              Close();
                     *              return;
                     *      }
                     *      else if (response == DialogResult.Yes)
                     *      {
                     *              IniPath = oldIniPath;
                     *              portable = false;
                     *      }
                     * }
                     */
                }

                if (!File.Exists(IniPath))
                {
                    File.WriteAllText(IniPath, Mix.GetString("noxico.ini"));
                }
                IniFile.Load(IniPath);

                if (portable)
                {
                    IniFile.SetValue("misc", "vistasaves", false);
                    IniFile.SetValue("misc", "savepath", "./saves");
                    IniFile.SetValue("misc", "shotpath", "./screenshots");
                }

                RestartGraphics(true);
                fourThirtySeven = IniFile.GetValue("misc", "437", false);

                Noxico = new NoxicoGame();
                Noxico.Initialize(this);

                MouseUp    += new MouseEventHandler(MainForm_MouseUp);
                MouseWheel += new MouseEventHandler(MainForm_MouseWheel);

                GotFocus  += (s, e) => { Vista.GamepadFocused = true; };
                LostFocus += (s, e) => { Vista.GamepadFocused = false; };

                Vista.GamepadEnabled = IniFile.GetValue("misc", "xinput", true);

                Program.WriteLine("Environment: {0} {1}", Environment.OSVersion.Platform, Environment.OSVersion);
                Program.WriteLine("Application: {0}", Application.ProductVersion);
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    Program.WriteLine("*** You are running on a *nix system. ***");
                    Program.WriteLine("Key repeat delays exaggerated.");
                    NoxicoGame.Mono      = true;
                    Vista.GamepadEnabled = false;
                }

                this.Controls.Clear();
                starting = false;
                Running  = true;

                Cursor           = new Point(-1, -1);
                cursorPens       = new Pen[3, 16];
                cursorPens[0, 0] = cursorPens[1, 0] = cursorPens[2, 0] = Pens.Black;
                for (var i = 1; i < 9; i++)
                {
                    cursorPens[0, i] = cursorPens[0, 16 - i] = new Pen(Color.FromArgb((i * 16) - 1, (i * 16) - 1, 0));
                    cursorPens[1, i] = cursorPens[1, 16 - i] = new Pen(Color.FromArgb(0, (i * 32) - 1, 0));
                    cursorPens[2, i] = cursorPens[2, 16 - i] = new Pen(Color.FromArgb((i * 32) - 1, (i * 32) - 1, (i * 32) - 1));
                }

                fpsTimer = new Timer()
                {
                    Interval = 1000,
                    Enabled  = true,
                };
                fpsTimer.Tick += (s, e) =>
                {
                    this.Text          = "Noxico - " + NoxicoGame.Updates + " updates, " + Frames + " frames";
                    NoxicoGame.Updates = 0;
                    Frames             = 0;
                };
#if GAMELOOP
                while (Running)
                {
                    Noxico.Update();
                    Application.DoEvents();
                }
#else
                FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
                var speed = IniFile.GetValue("misc", "speed", 15);
                if (speed <= 0)
                {
                    speed = 15;
                }
                timer = new Timer()
                {
                    Interval = speed,
                    Enabled  = true,
                };
                timer.Tick += new EventHandler(timer_Tick);
#endif
            }
#if !DEBUG
            catch (Exception x)
            {
                new ErrorForm(x).ShowDialog(this);
                SystemMessageBox.Show(this, x.ToString(), Application.ProductName, MessageBoxButtons.OK);
                Running = false;
                fatal   = true;
                Application.ExitThread();
            }
#endif
            if (!fatal)
            {
                Noxico.SaveGame();
            }
        }
Esempio n. 9
0
        public static void Handler()
        {
            if (Subscreens.FirstDraw)
            {
                Subscreens.FirstDraw = false;
                if (!FromTitle)
                {
                    UIManager.Initialize();
                    UIManager.Elements.Clear();
                }
                else
                {
                    //Leave the title screen background
                    UIManager.Highlight = UIManager.Elements[0];
                    UIManager.Elements.RemoveRange(3, UIManager.Elements.Count - 3);
                }

                window = new UIWindow(i18n.GetString("opt_title"))
                {
                    Left   = 0,
                    Top    = 0,
                    Width  = 80,
                    Height = 25,
                };
                window.Center();

                var speedLabel = new UILabel(i18n.GetString("opt_speed"));
                speedLabel.Move(3, 2, window);
                speed = new UITextBox(IniFile.GetValue("misc", "speed", "15"))
                {
                    Width   = 4,
                    Numeric = true
                };
                speed.Move(1, 1, speedLabel);

                var fonts            = Mix.GetFilesWithPattern("fonts\\*.png").Select(x => System.IO.Path.GetFileNameWithoutExtension(x)).ToArray();
                var currentFont      = IniFile.GetValue("misc", "font", "8x8-thin");
                var currentFontIndex = 0;
                if (fonts.Contains(currentFont))
                {
                    for (currentFontIndex = 0; currentFontIndex < fonts.Length; currentFontIndex++)
                    {
                        if (fonts[currentFontIndex] == currentFont)
                        {
                            break;
                        }
                    }
                }
                var fontLabel = new UILabel(i18n.GetString("opt_font"));
                fontLabel.Move(0, 3, speedLabel);
                font = new UIList(string.Empty, null, fonts, currentFontIndex)
                {
                    Width  = 20,
                    Height = 8,
                };
                font.Move(1, 1, fontLabel);
                font.Enter = (s, e) =>
                {
                    var previousFont = font.Text;
                    IniFile.SetValue("misc", "font", font.Text);
                    NoxicoGame.HostForm.RestartGraphics(false);
                    IniFile.SetValue("misc", "font", previousFont);
                };
                font.EnsureVisible();

                var screenColsLabel = new UILabel(i18n.GetString("opt_screencols"));
                screenColsLabel.MoveBelow(-1, 1, font);
                screenCols = new UITextBox(IniFile.GetValue("misc", "screencols", "80"))
                {
                    Width   = 4,
                    Numeric = true
                };
                screenCols.Move(1, 1, screenColsLabel);
                var screenRowsLabel = new UILabel(i18n.GetString("opt_screenrows"));
                screenRowsLabel.Move(-1, 1, screenCols);
                screenRows = new UITextBox(IniFile.GetValue("misc", "screenrows", "25"))
                {
                    Width   = 4,
                    Numeric = true
                };
                screenRows.Move(1, 1, screenRowsLabel);
                screenCols.Enter = screenRows.Enter = (s, e) =>
                {
                    var resetGraphics = false;
                    var i             = int.Parse(screenCols.Text);
                    if (i < 80)
                    {
                        i = 80;
                    }
                    if (i > 300)
                    {
                        i = 300;
                    }
                    if (i != Program.Cols)
                    {
                        resetGraphics = true;
                    }
                    Program.Cols = i;
                    IniFile.SetValue("misc", "screencols", i);
                    i = int.Parse(screenRows.Text);
                    if (i < 25)
                    {
                        i = 25;
                    }
                    if (i > 100)
                    {
                        i = 100;
                    }
                    if (i != Program.Rows)
                    {
                        resetGraphics = true;
                    }
                    Program.Rows = i;
                    IniFile.SetValue("misc", "screenrows", i);
                    if (resetGraphics)
                    {
                        NoxicoGame.HostForm.RestartGraphics(true);
                        window.Center();
                        UIManager.ReMove();
                    }
                    Subscreens.Redraw = true;
                    NoxicoGame.Me.CurrentBoard.AimCamera();
                    NoxicoGame.Me.CurrentBoard.Redraw();
                    NoxicoGame.Me.CurrentBoard.Draw();
                };

                var miscWindow = new UIWindow(i18n.GetString("opt_misc"))
                {
                    Width  = 50,
                    Height = 11,
                };
                miscWindow.MoveBeside(2, 0, speedLabel);

                rememberPause = new UIToggle(i18n.GetString("opt_rememberpause"))
                {
                    Checked    = IniFile.GetValue("misc", "rememberpause", true),
                    Background = Color.Transparent,
                };
                rememberPause.Move(2, 1, miscWindow);

                vistaSaves = new UIToggle(i18n.GetString("opt_vistasaves"))
                {
                    Checked    = IniFile.GetValue("misc", "vistasaves", true),
                    Enabled    = Vista.IsVista,
                    Background = Color.Transparent,
                };
                vistaSaves.MoveBelow(0, 1, rememberPause);

                xInput = new UIToggle(i18n.GetString("opt_xinput"))
                {
                    Checked    = IniFile.GetValue("misc", "xinput", true),
                    Enabled    = Vista.IsVista,
                    Background = Color.Transparent,
                };
                xInput.MoveBelow(0, 1, vistaSaves);

                imperial = new UIToggle(i18n.GetString("opt_imperial"))
                {
                    Checked    = IniFile.GetValue("misc", "imperial", false),
                    Background = Color.Transparent,
                };
                imperial.MoveBelow(0, 1, xInput);

                fourThirtySeven = new UIToggle(i18n.GetString("opt_437"))
                {
                    Checked    = IniFile.GetValue("misc", "437", false),
                    Background = Color.Transparent,
                };
                fourThirtySeven.MoveBelow(0, 1, imperial);

                var audioWindow = new UIWindow(i18n.GetString("opt_audio"))
                {
                    Width  = 30,
                    Height = 8,
                };
                audioWindow.MoveBelow(0, 1, miscWindow);

                enableAudio = new UIToggle(i18n.GetString("opt_enableaudio"))
                {
                    Checked    = IniFile.GetValue("audio", "enabled", true),
                    Background = Color.Transparent,
                };
                enableAudio.Move(2, 1, audioWindow);

                var musicVolumeLabel = new UILabel(i18n.GetString("opt_musicvolume"));
                musicVolumeLabel.MoveBelow(0, 1, enableAudio);
                musicVolume = new UITextBox(IniFile.GetValue("audio", "musicvolume", "100"));
                musicVolume.Move(1, 1, musicVolumeLabel);
                var soundVolumeLabel = new UILabel(i18n.GetString("opt_soundvolume"));
                soundVolumeLabel.Move(-1, 1, musicVolume);
                soundVolume = new UITextBox(IniFile.GetValue("audio", "soundvolume", "100"));
                soundVolume.Move(1, 1, soundVolumeLabel);

                saveButton = new UIButton(i18n.GetString("opt_save"), (s, e) =>
                {
                    var i = int.Parse(speed.Text);
                    if (i < 1)
                    {
                        i = 1;
                    }
                    if (i > 200)
                    {
                        i = 200;
                    }
                    IniFile.SetValue("misc", "speed", i);
                    IniFile.SetValue("misc", "font", font.Text);
                    IniFile.SetValue("misc", "rememberpause", rememberPause.Checked);
                    IniFile.SetValue("misc", "vistasaves", vistaSaves.Checked);
                    IniFile.SetValue("misc", "xinput", xInput.Checked);
                    IniFile.SetValue("misc", "imperial", imperial.Checked);
                    IniFile.SetValue("misc", "437", fourThirtySeven.Checked);
                    Vista.GamepadEnabled = xInput.Checked;

                    var resetGraphics = false;
                    i = int.Parse(screenCols.Text);
                    if (i < 80)
                    {
                        i = 80;
                    }
                    if (i > 300)
                    {
                        i = 300;
                    }
                    if (i != Program.Cols)
                    {
                        resetGraphics = true;
                    }
                    Program.Cols = i;
                    IniFile.SetValue("misc", "screencols", i);
                    i = int.Parse(screenRows.Text);
                    if (i < 25)
                    {
                        i = 25;
                    }
                    if (i > 100)
                    {
                        i = 100;
                    }
                    if (i != Program.Rows)
                    {
                        resetGraphics = true;
                    }
                    Program.Rows = i;
                    IniFile.SetValue("misc", "screenrows", i);

                    IniFile.SetValue("misc", "imperial", imperial.Checked);
                    IniFile.SetValue("audio", "enabled", enableAudio.Checked);
                    i = int.Parse(musicVolume.Text);
                    if (i < 0)
                    {
                        i = 0;
                    }
                    if (i > 100)
                    {
                        i = 100;
                    }
                    NoxicoGame.Sound.MusicVolume = i / 100f;
                    IniFile.SetValue("audio", "musicvolume", i);
                    i = int.Parse(soundVolume.Text);
                    if (i < 0)
                    {
                        i = 0;
                    }
                    if (i > 100)
                    {
                        i = 100;
                    }
                    NoxicoGame.Sound.SoundVolume = i / 100f;
                    IniFile.SetValue("audio", "soundvolume", i);

                    if (!enableAudio.Checked && NoxicoGame.Sound != null)
                    {
                        NoxicoGame.Sound.ShutDown();
                    }
                    else if (enableAudio.Checked && !NoxicoGame.Sound.Enabled)
                    {
                        NoxicoGame.Sound = new SoundSystem();
                        if (NoxicoGame.Me.CurrentBoard != null)
                        {
                            NoxicoGame.Me.CurrentBoard.PlayMusic();
                        }
                    }

                    if (resetGraphics)
                    {
                        NoxicoGame.HostForm.RestartGraphics(true);
                    }

                    IniFile.Save(string.Empty);
                    cancelButton.DoEnter();
                })
                {
                    Width = 16
                };
                saveButton.MoveBeside(2, 0, audioWindow);
                keysButton = new UIButton(i18n.GetString("opt_keys"), (s, e) =>
                {
                    Controls.Open();
                })
                {
                    Width = 16
                };
                keysButton.MoveBelow(0, 1, saveButton);
                openButton = new UIButton(i18n.GetString("opt_open"), (s, e) =>
                {
                    System.Diagnostics.Process.Start(NoxicoGame.HostForm.IniPath);
                })
                {
                    Width = 16
                };
                openButton.MoveBelow(0, 1, keysButton);
                cancelButton = new UIButton(i18n.GetString("opt_cancel"), (s, e) =>
                {
                    UIManager.Elements.Clear();
                    NoxicoGame.ClearKeys();
                    NoxicoGame.Immediate = true;
                    NoxicoGame.Me.CurrentBoard.Redraw();
                    NoxicoGame.Me.CurrentBoard.Draw(true);
                    NoxicoGame.Mode = UserMode.Walkabout;
                    if (FromTitle)
                    {
                        Introduction.Title();
                    }
                    Subscreens.FirstDraw = true;
                })
                {
                    Width = 16
                };
                cancelButton.MoveBelow(0, 1, openButton);

                UIManager.Elements.Add(window);
                UIManager.Elements.Add(speedLabel);
                UIManager.Elements.Add(speed);
                UIManager.Elements.Add(fontLabel);
                UIManager.Elements.Add(font);
                UIManager.Elements.Add(screenColsLabel);
                UIManager.Elements.Add(screenCols);
                UIManager.Elements.Add(screenRowsLabel);
                UIManager.Elements.Add(screenRows);
                UIManager.Elements.Add(miscWindow);
                UIManager.Elements.Add(rememberPause);
                UIManager.Elements.Add(vistaSaves);
                UIManager.Elements.Add(xInput);
                UIManager.Elements.Add(imperial);
                UIManager.Elements.Add(fourThirtySeven);
                UIManager.Elements.Add(audioWindow);
                UIManager.Elements.Add(enableAudio);
                UIManager.Elements.Add(musicVolumeLabel);
                UIManager.Elements.Add(musicVolume);
                UIManager.Elements.Add(soundVolumeLabel);
                UIManager.Elements.Add(soundVolume);
                UIManager.Elements.Add(saveButton);
                UIManager.Elements.Add(keysButton);
                UIManager.Elements.Add(openButton);
                UIManager.Elements.Add(cancelButton);

                Subscreens.FirstDraw = false;
                Subscreens.Redraw    = true;
            }
            if (Subscreens.Redraw)
            {
                Subscreens.Redraw = false;
                UIManager.Draw();
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.Back) || Vista.Triggers == XInputButtons.B)
            {
                cancelButton.DoEnter();
            }
            else
            {
                UIManager.CheckKeys();
            }
        }
Esempio n. 10
0
        public static void Handler()
        {
            var host = NoxicoGame.HostForm;

            if (Subscreens.FirstDraw)
            {
                Subscreens.FirstDraw = false;
                UIManager.Initialize();
                UIManager.Elements.Add(new UIWindow(i18n.GetString("pause_title"))
                {
                    Left = 3, Top = 1, Width = 22, Height = pages.Count + 2
                });
                UIManager.Elements.Add(new UIWindow(string.Empty)
                {
                    Left = 28, Top = 1, Width = 49, Height = 23
                });
                list = new UIList()
                {
                    Width = 20, Height = pages.Count, Left = 4, Top = 2, Background = UIColors.WindowBackground
                };
                list.Items.AddRange(pages.Keys);
                list.Change += (s, e) =>
                {
                    page      = list.Index;
                    text.Text = pages.Values.ElementAt(page);
                    UIManager.Draw();
                };
                list.Enter += (s, e) =>
                {
                    if (list.Index == list.Items.Count - 1)                     //can't use absolute index because Debug might be missing.
                    {
                        host.Close();
                    }
                    else if (list.Index == list.Items.Count - 2)                     //same
                    {
                        //System.Diagnostics.Process.Start(host.IniPath);
                        Options.Open();
                    }
                    else if (list.Index == 4)
                    {
                        TextScroller.Plain(Mix.GetString("credits.txt"), i18n.GetString("pause_credits"), false);
                    }
                };
                text = new UILabel("...")
                {
                    Left = 30, Top = 2
                };
                UIManager.Elements.Add(list);
                UIManager.Elements.Add(text);
                list.Index          = IniFile.GetValue("misc", "rememberpause", true) ? page : 0;
                UIManager.Highlight = list;

                Subscreens.Redraw = true;
            }
            if (Subscreens.Redraw)
            {
                Subscreens.Redraw = false;
                UIManager.Draw();
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.Back) || Vista.Triggers == XInputButtons.B)
            {
                NoxicoGame.ClearKeys();
                NoxicoGame.Immediate = true;
                NoxicoGame.Me.CurrentBoard.Redraw();
                NoxicoGame.Me.CurrentBoard.Draw(true);
                NoxicoGame.Mode      = UserMode.Walkabout;
                Subscreens.FirstDraw = true;
            }
            else
            {
                UIManager.CheckKeys();
            }
        }
Esempio n. 11
0
        public static void Open()
        {
            var host   = NoxicoGame.HostForm;
            var nox    = host.Noxico;
            var player = nox.Player.Character;

            var hpNow  = player.Health;
            var hpMax  = player.MaximumHealth;
            var health = hpNow + " / " + hpMax;

            if (hpNow <= hpMax / 4)
            {
                health = "<cRed>" + health + "<cSilver>";
            }
            else if (hpNow <= hpMax / 2)
            {
                health = "<cYellow>" + health + "<cSilver>";
            }

            var sb = new StringBuilder();

            sb.AppendLine(i18n.GetString("pause_name").PadEffective(20) + player.Name);
            sb.AppendLine(i18n.GetString("pause_gender").PadEffective(20) + player.Gender);
            sb.AppendLine(i18n.GetString("pause_health").PadEffective(20) + health);
            sb.AppendLine(i18n.GetString("pause_money").PadEffective(20) + player.GetToken("money").Value.ToString("C"));
            sb.AppendLine(i18n.GetString("pause_playtime").PadEffective(20) + nox.Player.PlayingTime.ToString());
            sb.AppendLine(i18n.GetString("pause_worldtime").PadEffective(20) + NoxicoGame.InGameTime.ToString());
            sb.AppendLine();

            player.RecalculateStatBonuses();
            player.CheckHasteSlow();
            foreach (var stat in Lua.Environment.stats)
            {
                if (stat.Value.panel == null)
                {
                    continue;
                }
                string properName = stat.Value.name.ToString();
                string statName   = properName.ToLowerInvariant();
                if (!player.HasToken(statName))
                {
                    sb.AppendLine(properName.PadEffective(20) + "<cGray>-?-");
                }
                else
                {
                    var bonus     = string.Empty;
                    var statBonus = player.GetToken(statName + "bonus").Value;
                    var statBase  = player.GetToken(statName).Value;
                    var total     = statBase + statBonus;
                    if (statBonus > 0)
                    {
                        bonus = "<cGray> (" + statBase + "+" + statBonus + ")<cSilver>";
                    }
                    else if (statBonus < 0)
                    {
                        bonus = "<cFirebrick> (" + statBase + "-" + (-statBonus) + ")<cSilver>";
                    }
                    sb.AppendLine(properName.PadEffective(20) + total + bonus);
                }
            }

            pages[i18n.GetString("pause_charstats")] = sb.ToString();

            sb.Clear();
            foreach (var skill in player.GetToken("skills").Tokens)
            {
                if ((int)skill.Value > 0)
                {
                    var skillName = i18n.GetString("skill_" + skill.Name);
                    if (skillName[0] == '[')                     //Ignore missing skill translations for now.
                    {
                        skillName = skillName.Substring(7, skillName.Length - 8);
                    }
                    sb.AppendLine(skillName.Replace('_', ' ').Titlecase().PadEffective(30) + ((int)skill.Value).ToString());
                }
            }
            pages[i18n.GetString("pause_skills")] = sb.ToString();

            sb.Clear();
            for (var i = 0; i < 4; i++)
            {
                sb.Append(Toolkit.TranslateKey((KeyBinding)i));
            }
            sb.AppendLine("         - " + i18n.GetString("pause_keymove"));
            sb.AppendLine(Toolkit.TranslateKey(KeyBinding.Interact, true).PadEffective(12) + " - " + i18n.GetString("pause_keyinteract"));
            sb.AppendLine(Toolkit.TranslateKey(KeyBinding.Activate, true).PadEffective(12) + " - " + i18n.GetString("pause_keyactivate"));
            sb.AppendLine(Toolkit.TranslateKey(KeyBinding.Rest, true).PadEffective(12) + " - " + i18n.GetString("pause_keyrest"));
            sb.AppendLine(Toolkit.TranslateKey(KeyBinding.Fly, true).PadEffective(12) + " - " + i18n.GetString("pause_keyfly"));
            sb.AppendLine(Toolkit.TranslateKey(KeyBinding.Items, true).PadEffective(12) + " - " + i18n.GetString("pause_keyitems"));
            sb.AppendLine(Toolkit.TranslateKey(KeyBinding.Travel, true).PadEffective(12) + " - " + i18n.GetString("pause_keytravel"));
            sb.AppendLine(Toolkit.TranslateKey(KeyBinding.Accept, true).PadEffective(12) + " - " + i18n.GetString("pause_keyaccept"));
            sb.AppendLine(Toolkit.TranslateKey(KeyBinding.Back, true).PadEffective(12) + " - " + i18n.GetString("pause_keyback"));
            pages[i18n.GetString("pause_keys1")] = sb.ToString();
            sb.Clear();
            sb.AppendLine(Toolkit.TranslateKey(KeyBinding.Pause, true).PadEffective(8) + " - " + i18n.GetString("pause_keypause"));
#if DEBUG
            sb.AppendLine(Toolkit.TranslateKey(System.Windows.Forms.Keys.F3, true).PadEffective(8) + " - Dump board to HTML (debug only)");
#endif
            sb.AppendLine(Toolkit.TranslateKey(KeyBinding.Screenshot, true).PadEffective(8) + " - " + i18n.GetString("pause_keyscreenshot"));
            pages[i18n.GetString("pause_keys2")] = sb.ToString();

#if DEBUG
            var entities = 0;
            var tokens   = 0;
            foreach (var x in nox.Boards.Where(x => x != null))
            {
                if (x == null)
                {
                    continue;
                }
                entities += x.Entities.Count;
                foreach (var c in x.Entities.OfType <BoardChar>())
                {
                    tokens += c.Character.Tokens.Count;
                    foreach (var t in c.Character.Tokens)
                    {
                        tokens += CountTokens(t);
                    }
                }
            }
            ;
            NoxicoGame.KnownItems.ForEach(x =>
            {
                tokens += x.Tokens.Count;
                foreach (var t in x.Tokens)
                {
                    tokens += CountTokens(t);
                }
            });

            pages[i18n.GetString("pause_memstats")] = i18n.Format("pause_memstatscontent",
                                                                  nox.Boards.Count.ToString("G"),
                                                                  nox.Boards.Where(b => b != null).Count().ToString("G"),
                                                                  NoxicoGame.KnownItems.Count.ToString("G"),
                                                                  entities.ToString("G"),
                                                                  tokens.ToString("G"));
#endif

            if (!IniFile.GetValue("misc", "rememberpause", true))
            {
                page = 0;
            }

            NoxicoGame.Subscreen = Handler;
            NoxicoGame.Mode      = UserMode.Subscreen;
            Subscreens.FirstDraw = true;
            NoxicoGame.ClearKeys();
        }