Example #1
0
        protected override void DrawContents(Gdk.Drawable d)
        {
            Cairo.Context g = Gdk.CairoHelper.Create(d);

            g.SelectFontFace("Lucida Console", FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            TextExtents te;


            if (IsControl || MateriaArrange.Instance.IsControl || MateriaPrompt.Instance.IsControl)
            {
                int j = Math.Min(rows + topRow, Materiatory.MATERIATORY_SIZE);

                for (int i = topRow; i < j; i++)
                {
                    Materia orb = Materiatory.Get(i);
                    if (orb != null)
                    {
                        Graphics.RenderCircle(g, new Color(1, 1, 1), 9, X + x1, Y + cy + (i - topRow) * y);
                        Graphics.RenderCircle(g, orb.Color, 7, X + x1, Y + cy + (i - topRow) * y);

                        Graphics.ShadowedText(g, orb.Name, X + x2, Y + (i - topRow + 1) * y);
                    }
                }
            }

            if (IsControl)
            {
                Graphics.RenderCursor(g, X + cx, Y + cy + (option - topRow) * y);
            }

            ((IDisposable)g.Target).Dispose();
            ((IDisposable)g).Dispose();
        }
Example #2
0
 public static void SwapMateria(Armor before, Armor after, Character c)
 {
     for (int i = 0; i < before.Slots.Length; i++)
     {
         Materia m = before.Slots[i];
         if (m != null)
         {
             if (i > after.Slots.Length)
             {
                 m.Detach(c);
                 Materiatory.Put(m);
             }
             else
             {
                 after.Slots[i] = m;
             }
         }
         before.Slots[i] = null;
     }
 }
Example #3
0
        public override void ControlHandle(Key k)
        {
            switch (k)
            {
            case Key.Left:
                if (option > 0)
                {
                    option--;
                }
                break;

            case Key.Right:
                if (option < 1)
                {
                    option++;
                }
                break;

            case Key.Circle:
                switch (option)
                {
                case 0:
                    Materiatory.Put(null, MateriaList.Instance.Option);
                    MenuScreen.MateriaScreen.ChangeControl(MateriaList.Instance);
                    break;

                case 1:
                    MenuScreen.MateriaScreen.ChangeControl(MateriaList.Instance);
                    break;

                default: break;
                }
                break;

            case Key.X:
                MenuScreen.MateriaScreen.ChangeControl(MateriaList.Instance);
                break;

            default: break;
            }
        }
Example #4
0
        public override void ControlHandle(Key k)
        {
            switch (k)
            {
            case Key.Up:
                if (option > 0)
                {
                    option--;
                }
                if (topRow > option)
                {
                    topRow--;
                }
                break;

            case Key.Down:
                if (option < Materiatory.MATERIATORY_SIZE - 1)
                {
                    option++;
                }
                if (topRow < option - rows + 1)
                {
                    topRow++;
                }
                break;

            case Key.X:
                if (trashing)
                {
                    MenuScreen.MateriaScreen.ChangeControl(MateriaArrange.Instance);
                }
                else
                {
                    MenuScreen.MateriaScreen.ChangeToDefaultControl();
                }
                trashing = false;
                break;

            case Key.Circle:
                if (Trashing)
                {
                    MenuScreen.MateriaScreen.ChangeControl(MateriaPrompt.Instance);
                    break;
                }
                Materia neworb = Materiatory.Get(option);
                Materia oldorb;
                switch (MateriaTop.Instance.OptionY)
                {
                case 0:
                    oldorb = Selected.Weapon.Slots[MateriaTop.Instance.OptionX];
                    if (oldorb != null)
                    {
                        oldorb.Detach(Selected);
                    }
                    Materiatory.Put(oldorb, option);
                    if (neworb != null)
                    {
                        neworb.Attach(Selected);
                    }
                    Selected.Weapon.AttachMateria(neworb, MateriaTop.Instance.OptionX);
                    MenuScreen.MateriaScreen.ChangeToDefaultControl();
                    break;

                case 1:
                    oldorb = Selected.Armor.Slots[MateriaTop.Instance.OptionX];
                    if (oldorb != null)
                    {
                        oldorb.Detach(Selected);
                    }
                    Materiatory.Put(oldorb, option);
                    if (neworb != null)
                    {
                        neworb.Attach(Selected);
                    }
                    Selected.Armor.AttachMateria(neworb, MateriaTop.Instance.OptionX);
                    MenuScreen.MateriaScreen.ChangeToDefaultControl();
                    break;

                default: break;
                }
                break;

            default:
                break;
            }
        }
Example #5
0
        public override void ControlHandle(Key k)
        {
            switch (k)
            {
            case Key.Up:
                if (optionY > 0)
                {
                    optionY--;
                }
                break;

            case Key.Down:
                if (optionY < 1)
                {
                    optionY++;
                }
                break;

            case Key.Left:
                if (optionX > -1)
                {
                    optionX--;
                }
                break;

            case Key.Right:
                if (optionX < 7)
                {
                    optionX++;
                }
                break;

            case Key.X:
                Game.MainMenu.ChangeScreen(MenuScreen.MainScreen);
                break;

            case Key.Square:
                Game.MainMenu.ChangeScreen(MenuScreen.EquipScreen);
                break;

            case Key.Circle:
                if (optionX == -1)
                {
                    switch (optionY)
                    {
                    case 0:         // check
                        break;

                    case 1:         // arrange
                        MenuScreen.MateriaScreen.ChangeControl(MateriaArrange.Instance);
                        break;

                    default: break;
                    }
                }
                else
                {
                    switch (optionY)
                    {
                    case 0:
                        if (optionX < Selected.Weapon.Slots.Length)
                        {
                            MenuScreen.MateriaScreen.ChangeControl(MateriaList.Instance);
                        }
                        break;

                    case 1:
                        if (optionX < Selected.Armor.Slots.Length)
                        {
                            MenuScreen.MateriaScreen.ChangeControl(MateriaList.Instance);
                        }
                        break;
                    }
                }
                break;

            case Key.Triangle:
                if (optionX == -1)
                {
                    break;
                }
                Materia orb;
                switch (optionY)
                {
                case 0:
                    orb = Selected.Weapon.Slots[optionX];
                    if (orb != null)
                    {
                        Selected.Weapon.Slots[optionX] = null;
                        orb.Detach(Selected);
                        Materiatory.Put(orb);
                    }
                    break;

                case 1:
                    orb = Selected.Armor.Slots[optionX];
                    if (orb != null)
                    {
                        Selected.Armor.Slots[optionX] = null;
                        orb.Detach(Selected);
                        Materiatory.Put(orb);
                    }
                    break;

                default: break;
                }
                break;

            default:
                break;
            }
            switch (optionY)
            {
            case 0: cy = yi; break;

            case 1: cy = yk; break;

            default: break;
            }
            if (optionX == -1)
            {
                cx = x7;
            }
            else
            {
                cx = x9 + optionX * xs;
            }
        }
Example #6
0
        public override void ControlHandle(Key k)
        {
            switch (k)
            {
            case Key.Up:
                if (option > 0)
                {
                    option--;
                }
                break;

            case Key.Down:
                if (option < 3)
                {
                    option++;
                }
                break;

            case Key.Circle:
                switch (option)
                {
                case 0:
                    Materiatory.Sort();
                    break;

                case 1:
                    break;

                case 2:
                    for (int i = 0; i < Selected.Weapon.Slots.Length; i++)
                    {
                        Materia orb = Selected.Weapon.Slots[i];
                        if (orb != null)
                        {
                            Selected.Weapon.Slots[i] = null;
                            orb.Detach(Selected);
                            Materiatory.Put(orb);
                        }
                    }
                    for (int j = 0; j < Selected.Armor.Slots.Length; j++)
                    {
                        Materia orb = Selected.Armor.Slots[j];
                        if (orb != null)
                        {
                            Selected.Armor.Slots[j] = null;
                            orb.Detach(Selected);
                            Materiatory.Put(orb);
                        }
                    }
                    break;

                case 3:
                    MenuScreen.MateriaScreen.ChangeControl(MateriaList.Instance);
                    MateriaList.Instance.Trashing = true;
                    break;

                default: break;
                }
                break;

            case Key.X:
                Visible = false;
                MenuScreen.MateriaScreen.ChangeToDefaultControl();
                break;

            default: break;
            }
        }
Example #7
0
        private static void Init()
        {
            _random = new Random();

            InitializeLua();

            Application.Init();
            if (!GLib.Thread.Supported)
            {
                GLib.Thread.Init();
            }
            Gdk.Threads.Init();

            Gdk.Threads.Enter();

            _window = new Gtk.Window(Globals.WINDOW_NAME);
            _window.SetDefaultSize(Globals.WIDTH, Globals.HEIGHT);
            _window.AppPaintable     = true;
            _window.DoubleBuffered   = false;
            _window.DeleteEvent     += OnWinDelete;
            _window.KeyPressEvent   += OnKeyPress;
            _window.KeyReleaseEvent += OnKeyRelease;
            //_window.ConfigureEvent += OnWindowConfigure;

            DrawingArea da = new DrawingArea();

            da.ExposeEvent += OnExposed;

            Gdk.Color col = new Gdk.Color(0, 0, 0);
            _window.ModifyBg(StateType.Normal, col);
            da.ModifyBg(StateType.Normal, col);

            GLib.Timeout.Add(33, new GLib.TimeoutHandler(Graphics.TimedDraw));

            _window.Add(da);
            _window.ShowAll();

            Gdk.Threads.Leave();

            Graphics.Init();    // depends on _window being initialized
            Item.Init();
            Enemy.Init();       // depends on Globals ctor
            Weapon.Init();      // depends on Globals ctor
            Armor.Init();       // depends on Globals ctor
            Accessory.Init();   // depends on Globals ctor
            Materia.Init();     // depends on Globals ctor
            Character.Init();   // depends on [Weapons|Armor|Materia].Init()
            Globals.Init();     // depends on Character.Init()
            MenuScreen.Init();  // depends on Globals.Init()
            Inventory.Init();   // depends on a whole lot of things
            Spell.Init();       // depends on Globals ctor
            Materiatory.Init(); // depends on Materia.Init()

            int time = Int32.Parse(Globals.SaveGame.SelectSingleNode("//time").InnerText);

            _clock = new Clock(time); // depends on Globals ctor

            // Go to Main Menu
            _state = MainMenu;

            // Go to new Battle
            //GoToBattleState();

            // Go to Post-Battle
            //List<IItem> i = new List<IItem>();
            //i.Add(Item.ItemTable["powersource"]);
            //i.Add(Item.ItemTable["powersource"]);
            //i.Add(Item.ItemTable["potion"]);
            //PostBattle = new PostBattleState(234, 12, 1200, i);
            //_state = PostBattle;

            _state.Init();

            if (Globals.Party[0] == null && Globals.Party[1] == null && Globals.Party[2] == null)
            {
                throw new GamedataException("No character in party!");
            }

            // Level-up demo
            //using (StreamWriter w = new StreamWriter(@"c:\scripts\test.txt"))
            //{
            //    while (Character.Cloud.Level < 98)
            //    {
            //        Character.Cloud.GainExperience(Character.Cloud.ToNextLevel + 10);
            //        w.WriteLine(Character.Cloud.ToString());
            //    }
            //    w.Flush();
            //}
        }