Example #1
0
        public MainWindowViewModel()
        {
            GuiModelData = new GuiModel
            {
                GitHubToken = ConfigSetGet.GetConfigData("GitHubToken")
            };
            GuiModelData.PropertyChanged += guiModelDataPropertyChanged;

            _gitHubDownloader = new GitHubDownloader(GuiModelData)
            {
                Finished = url =>
                {
                    addLog(string.Format("Finished {0}.", url));
                    _isStarted = false;
                }
            };

            StartCommand = new DelegateCommand <string>(doStart, canDoStart);
            StopCommand  = new DelegateCommand <string>(doStop, stat => true);

            AppMessenger.Messenger.Register <string>("ShowLog", log => addLog(log));
            manageAppExit();
        }
Example #2
0
        public MainWindowViewModel()
        {
            GuiState = new GuiModel
            {
                GitHubToken = PersistentConfig.GetConfigData("GitHubToken")
            };

            GuiState.WhenAnyValue(p => p.RepositoryFolderFullUrl)
            .Throttle(TimeSpan.FromMilliseconds(250))
            .Subscribe(_ => ValidateAndExecuteURL(_));

            _gitHubDownloader = new GitHubDownloader(GuiState)
            {
                Finished = url =>
                {
                    Trace.WriteLine($"Finished {url}.", "Info");
                    DispatcherHelper.DispatchAction(() => GuiState.HasStarted = false);
                }
            };

            StartCommand      = ReactiveCommand.Create(() => StartDownload(), CanStartDownloadExecute);
            StopCommand       = ReactiveCommand.Create(() => StopDownload());
            OpenFolderCommand = ReactiveCommand.Create(() => GetSaveFolder());
        }
Example #3
0
 public Label(Vector2 pos, Vector2 size, string textstring, TextStyle style)
 {
     this.pos  = pos;
     this.text = new Text(textstring, style, new Vector2(pos.x, pos.y + 0.05));
     model     = GuiModel.CreateRectangle(size, Textures.LabelTex);
 }
 public ApiUrl(GuiModel guiModelData)
 {
     _guiModelData = guiModelData;
 }
 public GitHubBranchList(GuiModel guiModelData)
 {
     _guiModelData = guiModelData;
 }
Example #6
0
 private static void RenderInstance(GuiModel model, Vector2 position, Vector3 colour)
 {
     RenderInstance(model, position, new Vector4(colour.x, colour.y, colour.z, 1));
 }
Example #7
0
 private static void RenderInstance(GuiModel model, Vector2 position)
 {
     RenderInstance(model, position, new Vector3(1, 1, 1));
 }
Example #8
0
 public ApiUrl(GuiModel GuiState)
 {
     _GuiState = GuiState;
 }
Example #9
0
 public GitHubDownloader(GuiModel guiModelData)
 {
     _guiModelData = guiModelData;
 }
 public GitHubDownloader(GuiModel GuiState)
 {
     _GuiState = GuiState;
 }
Example #11
0
 public MainWindowViewModel()
 {
     GuiModelData = new GuiModel();
     DoStart      = new DelegateCommand <string>(data => processFiles(), s => true);
 }
Example #12
0
 protected virtual GuiModel GenModel()
 {
     return(GuiModel.CreateRectangle(size, Textures.TextboxTex));
 }
Example #13
0
 protected override GuiModel GenModel()
 {
     return(GuiModel.CreateRectangle(size, TextureUtil.CreateTexture(0.2f, 0.2f, 0.2f, 0.4f)));
 }
Example #14
0
        public static void Init()
        {
            Vector2 buttonSize = new Vector2(0.3, 0.08);

            btn_Back_Title = new Button(new Vector2(0, -0.7), buttonSize, "Back", TextStyle.Chiller_SingleLine_Large, delegate() { SwitchTo(State.Main); });
            backgroundhue  = 180;

            #region Home Screen
            btn_Main_Play    = new Button(new Vector2(0, 0.3), buttonSize, "Play", TextStyle.Chiller_SingleLine_Large, delegate() { SwitchTo(State.WorldSelect); });
            btn_Main_Credits = new Button(new Vector2(0, -0.05), buttonSize, "Credits", TextStyle.Chiller_SingleLine_Large, delegate() { SwitchTo(State.Credits); });
            btn_Main_Help    = new Button(new Vector2(0, -0.4), buttonSize, "Help", TextStyle.Chiller_SingleLine_Large, delegate() { SwitchTo(State.Help); });
            btn_Main_Exit    = new Button(new Vector2(0, -0.75), buttonSize, "Exit", TextStyle.Chiller_SingleLine_Large, delegate() { Glut.glutLeaveMainLoop(); });
            #endregion

            #region Background
            txt_Main_Title = new Text("TITLE HERE", new TextStyle(TextAlignment.Center, TextFont.Chiller, 3f, 2f, 1, 1f, new Vector3(1, 1, 1)), new Vector2(0, 1));
            backgroundpos  = Vector2.Zero;
            float s = 1f / Program.AspectRatio;
            float imageAspectRatio = (float)Textures.TitleBackgroundTex.Size.Width / Textures.TitleBackgroundTex.Size.Height;
            background = GuiModel.CreateRectangle(new Vector2(s * imageAspectRatio, s), Textures.TitleBackgroundTex);
            background.vao.UpdateUVs(new Vector2[] {
                backgroundpos + new Vector2(0, 1f),
                backgroundpos + new Vector2(0, 0),
                backgroundpos + new Vector2(1, 0),
                backgroundpos + new Vector2(1, 1f)
            });
            #endregion

            #region Credits
            TextStyle tstyle = new TextStyle(TextAlignment.Center, TextFont.Chiller, 0.8f, 1.8f, 1 << 30, 0.5f, new Vector3(1, 1, 1));
            txt_CreditsInfo = new Text("Copyright Alex Tan (2016). Apache License. https://github.com/Pilex1/2D-Game/blob/master/LICENSE" + Environment.NewLine + Environment.NewLine + "- code, bugs, game design, bugs, graphics, bugs, everything you see here, bugs. Did I mention bugs?" + Environment.NewLine + Environment.NewLine + "Help me continue making these projects:" + Environment.NewLine + Environment.NewLine + "Visit my github repositories to view and download the full source code plus my other projects" + Environment.NewLine + " - https://github.com/Pilex1" + Environment.NewLine + " - https://github.com/Pilex1/2D-Game" + Environment.NewLine + Environment.NewLine + "Subscribe to my youtube channel where I post videos of Mandelbrot renders and game development" + Environment.NewLine + " - Pilex", tstyle, new Vector2(0, 0.9));
            #endregion

            #region World Pickers
            btnWorldPickers = new List <Button>();

            txtboxWorldPickers = new List <Textbox>();
            worlds             = new HashSet <string>();
            ResetWorldPickers();
            #endregion

            #region New World
            //creating new world
            txtbx_NewWorld_Name = new Textbox(new Vector2(0, 0.5), new Vector2(0.3, 0.03), TextFont.Chiller, 0.6f);
            txtbx_NewWorld_Seed = new Textbox(new Vector2(0, 0.2), new Vector2(0.3, 0.03), TextFont.Chiller, 0.6f);
            float offset = 0.15f;
            txt_NewWorld_Name        = new Text("World Name", tstyle, new Vector2(0, 0.5 + offset));
            txt_NewWorld_Seed        = new Text("Seed", tstyle, new Vector2(0, 0.2 + offset));
            btn_NewWorld_CreateWorld = new Button(new Vector2(0, -0.3), new Vector2(0.3, 0.08), "Create", TextStyle.Chiller_SingleLine_Large, delegate() {
                string worldname = txtbx_NewWorld_Name.GetText();
                worlds.Add(worldname);
                Program.SwitchToGame(worldname, int.Parse(txtbx_NewWorld_Seed.GetText()));
            });
            btn_NewWorld_RandSeed = new Button(new Vector2(0.5, 0.2), new Vector2(0.15, 0.03), "Random seed", TextStyle.Chiller_SingleLine_Small, delegate() {
                int irand = MathUtil.RandInt(Program.Rand, 1 << 24, 1 << 30);
                txtbx_NewWorld_Seed.SetText(irand.ToString());
            });
            btn_NewWorld_Back = new Button(new Vector2(0, -0.7), buttonSize, "Back", TextStyle.Chiller_SingleLine_Large, delegate() {
                txtbx_NewWorld_Name.ClearText();
                txtbx_NewWorld_Name.disabled = true;

                txtbx_NewWorld_Seed.ClearText();
                txtbx_NewWorld_Seed.disabled = true;

                SwitchTo(State.WorldSelect);
            });
            #endregion

            #region Help
            txt_Help = new Text("How to play:" + Environment.NewLine + "W A S D - movement" + Environment.NewLine + "Left click - destroy tile" + Environment.NewLine + "Right click - interact / place tile" + Environment.NewLine + "E - open / close inventory" + Environment.NewLine + "Mousewheel and keys 1 to 9 - hotbar selection" + Environment.NewLine + Environment.NewLine + "Debug controls: (pretend these don't exist)" + Environment.NewLine + "F1 - toggle tile data view" + Environment.NewLine + "F - toggle flying", tstyle, new Vector2(0, 0.9));
            #endregion

            SwitchTo(State.Main);
        }
Example #15
0
 public GitHubBranchList(GuiModel GuiState)
 {
     _GuiState = GuiState;
 }