private static Dictionary <string, ControlStyle> GetControlStyles() { var baseStyle = new ControlStyle() { Tiling = TextureMode.Grid, Grid = new Margin(3), Texture = GetTexturePath("button_hot"), Default = { Texture = GetTexturePath("button_default"), }, Pressed = { Texture = GetTexturePath("button_down"), }, Selected = { Texture = GetTexturePath("button_down"), }, Focused = { Texture = GetTexturePath("button_down"), }, SelectedPressed = { Texture = GetTexturePath("button_down"), }, SelectedHot = { Texture = GetTexturePath("button_down"), }, }; return(new Dictionary <string, ControlStyle>() { { "item", new ControlStyle(baseStyle) { TextPadding = new Margin(8, 0, 8, 0), TextAlign = Alignment.MiddleLeft, } }, { "button", new ControlStyle(baseStyle) { TextPadding = new Margin(0), TextAlign = Alignment.MiddleCenter, } }, { "tooltip", new ControlStyle(baseStyle) { TextPadding = new Margin(8), TextAlign = Alignment.TopLeft, } }, { "textbox", new ControlStyle(baseStyle) { Texture = GetTexturePath("input_default"), TextPadding = new Margin(8), Tiling = TextureMode.Grid, Grid = new Margin(3), Hot = { Texture = GetTexturePath("input_focused") }, Focused = { Texture = GetTexturePath("input_focused"), Tint = ColorInt.ARGB(1,1, 0, 0), }, } }, { "window", new ControlStyle() { Tiling = TextureMode.Grid, Grid = new Margin(9), Texture = GetTexturePath("window"), } }, { "frame", new ControlStyle() { Tiling = TextureMode.Grid, Grid = new Margin(4), Texture = GetTexturePath("frame"), TextPadding = new Margin(8), } }, { "vscrollTrack", new ControlStyle() { Tiling = TextureMode.Grid, Grid = new Margin(3), Texture = GetTexturePath("vscroll_track"), } }, { "vscrollButton", new ControlStyle() { Tiling = TextureMode.Grid, Grid = new Margin(3), Texture = GetTexturePath("vscroll_button"), Hot = { Texture = GetTexturePath("vscroll_button_hot"), }, Pressed = { Texture = GetTexturePath("vscroll_button_down"), }, } }, { "vscrollUp", new ControlStyle() { Default = { Texture = GetTexturePath("vscrollUp_default"), }, Hot = { Texture = GetTexturePath("vscrollUp_hot"), }, Pressed = { Texture = GetTexturePath("vscrollUp_down"), }, Focused = { Texture = GetTexturePath("vscrollUp_hot"), }, } }, { "hscrollTrack", new ControlStyle() { Tiling = TextureMode.Grid, Grid = new Margin(3), Texture = GetTexturePath("hscroll_track"), } }, { "hscrollButton", new ControlStyle() { Tiling = TextureMode.Grid, Grid = new Margin(3), Texture = GetTexturePath("hscroll_button"), Hot = { Texture = GetTexturePath("hscroll_button_hot"), }, Pressed = { Texture = GetTexturePath("hscroll_button_down"), }, } }, { "hscrollUp", new ControlStyle() { Default = { Texture = GetTexturePath("hscrollUp_default"), }, Hot = { Texture = GetTexturePath("hscrollUp_hot"), }, Pressed = { Texture = GetTexturePath("hscrollUp_down"), }, Focused = { Texture = GetTexturePath("hscrollUp_hot"), }, } }, { "checkBox", new ControlStyle() { Default = { Texture = GetTexturePath("checkbox_default"), }, Hot = { Texture = GetTexturePath("checkbox_hot"), }, Pressed = { Texture = GetTexturePath("checkbox_down"), }, Checked = { Texture = GetTexturePath("checkbox_checked"), }, CheckedFocused = { Texture = GetTexturePath("checkbox_checked_hot"), }, CheckedHot = { Texture = GetTexturePath("checkbox_checked_hot"), }, CheckedPressed = { Texture = GetTexturePath("checkbox_down"), }, } }, { "comboLabel", new ControlStyle() { TextPadding = new Margin(10, 0, 0, 0), Tiling = TextureMode.Grid, Grid = new Margin(3, 0, 0, 0), Default = { Texture = GetTexturePath("combo_default"), }, Hot = { Texture = GetTexturePath("combo_hot"), }, Pressed = { Texture = GetTexturePath("combo_down"), }, Focused = { Texture = GetTexturePath("combo_hot"), }, } }, { "comboButton", new ControlStyle() { Default = { Texture = GetTexturePath("combo_button_default"), }, Hot = { Texture = GetTexturePath("combo_button_hot"), }, Pressed = { Texture = GetTexturePath("combo_button_down"), }, Focused = { Texture = GetTexturePath("combo_button_hot"), }, } }, { "multiline", new ControlStyle() { TextPadding = new Margin(8), TextAlign = Alignment.TopLeft, } }, { "label", new ControlStyle() { TextPadding = new Margin(8, 0, 8, 0), TextAlign = Alignment.MiddleLeft, TextColor = ColorInt.ARGB(1, .8f, .8f, .8f), BackColor = 0, } }, }); }
private Frame CreateAnswerFrame(QuestionProgress questionProgress, QuestionAnswer questionAnswer) { Button showFeedbackButton = new Button(); showFeedbackButton.Dock = DockStyle.Fill; showFeedbackButton.Style = "Button - Rounded"; showFeedbackButton.Text = "?"; showFeedbackButton.UseTextColor = true; showFeedbackButton.Visible = false; Frame feedbackButtonFrame = new Frame(); feedbackButtonFrame.AutoSize = Squid.AutoSize.Vertical; feedbackButtonFrame.Dock = DockStyle.Right; feedbackButtonFrame.Size = new Point(42, 31); feedbackButtonFrame.Controls.Add(showFeedbackButton); Button chooseAnswerButton = new Button(); chooseAnswerButton.Dock = DockStyle.Fill; chooseAnswerButton.Style = "Button - Pointed"; ImageControl answerIndicatorImage = new ImageControl(); answerIndicatorImage.Dock = DockStyle.Center; answerIndicatorImage.Size = new Point(22, 22); answerIndicatorImage.Texture = "circle_frame"; answerIndicatorImage.Visible = false; Frame answerIndicatorFrame = new Frame(); answerIndicatorFrame.AutoSize = Squid.AutoSize.Vertical; answerIndicatorFrame.Dock = DockStyle.Left; answerIndicatorFrame.Margin = new Squid.Margin(12, 0, 0, 0); answerIndicatorFrame.Size = new Point(22, 26); answerIndicatorFrame.Controls.Add(answerIndicatorImage); Label questionTextLabel = new Label(); questionTextLabel.Style = "Label - Bold"; questionTextLabel.AutoSize = Squid.AutoSize.Vertical; questionTextLabel.Dock = DockStyle.Fill; questionTextLabel.UseTextColor = true; questionTextLabel.AutoEllipsis = false; questionTextLabel.TextWrap = true; questionTextLabel.NoEvents = true; questionTextLabel.Text = questionAnswer.QuestionAnswerText; Frame answerFrame = new Frame(); answerFrame.AutoSize = Squid.AutoSize.Vertical; answerFrame.Dock = DockStyle.Top; answerFrame.Margin = new Squid.Margin(12, 0, 12, 3); answerFrame.Controls.Add(feedbackButtonFrame); answerFrame.Controls.Add(chooseAnswerButton); answerFrame.Controls.Add(answerIndicatorFrame); answerFrame.Controls.Add(questionTextLabel); _questionAnswered += (chosenAnswer) => { // When a question is answered, if it's the correct question or this question, then show the feedback button. if (chosenAnswer == questionProgress.CorrectAnswer || chosenAnswer == questionAnswer) { // Show feedback frame because either the correct answer was chosen or this answer was chosen. showFeedbackButton.Visible = true; chooseAnswerButton.NoEvents = true; // Change color if (questionProgress.CorrectAnswer == questionAnswer) { questionTextLabel.TextColor = ColorInt.ARGB(255, 136, 255, 137); answerIndicatorImage.Visible = true; answerIndicatorImage.Color = ColorInt.ARGB(255, 136, 255, 137); GameContext.Instance.Player.Points += questionProgress.CalculatePoints(); } else { questionTextLabel.TextColor = ColorInt.ARGB(255, 255, 86, 86); if (questionProgress.AnswerChosen(questionAnswer)) { answerIndicatorImage.Visible = true; answerIndicatorImage.Color = ColorInt.ARGB(255, 255, 86, 86); } } } }; if (questionProgress.AnswerChosen(questionAnswer) || questionProgress.Completed) { showFeedbackButton.Visible = true; chooseAnswerButton.NoEvents = true; if (questionAnswer == questionProgress.CorrectAnswer) { // answered correctly chooseAnswerButton.State = ControlState.Pressed; questionTextLabel.TextColor = ColorInt.ARGB(255, 136, 255, 137); answerIndicatorImage.Visible = true; answerIndicatorImage.Color = ColorInt.ARGB(255, 136, 255, 137); } else { // answered incorrectly questionTextLabel.TextColor = ColorInt.ARGB(255, 255, 86, 86); if (questionProgress.AnswerChosen(questionAnswer)) { chooseAnswerButton.State = ControlState.Pressed; answerIndicatorImage.Visible = true; answerIndicatorImage.Color = ColorInt.ARGB(255, 255, 86, 86); } } } showFeedbackButton.MouseClick += (s, a) => { _feedbackFrame.Visible = true; _answerFrame.Visible = false; _feedbackLabel.Text = questionAnswer.QuestionFeedback; _feedbackQuestion.Text = questionAnswer.QuestionAnswerText; _feedbackQuestion.TextColor = questionProgress.CorrectAnswer == questionAnswer?ColorInt.ARGB(255, 136, 255, 137) : ColorInt.ARGB(255, 255, 86, 86); }; chooseAnswerButton.MouseClick += (s, a) => { if (questionProgress.Completed || questionProgress.AnswerChosen(questionAnswer)) { return; } questionProgress.ChooseAnswer(questionAnswer); _questionAnswered(questionAnswer); }; return(answerFrame); }
private Frame Create3DPreviewButton(BiologEntry entry) { Frame navigatorFrame = new Frame(); navigatorFrame.Dock = DockStyle.Left; navigatorFrame.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; navigatorFrame.Margin = new Margin(0, 0, 0, 0); navigatorFrame.NoEvents = true; navigatorFrame.Size = new Point(100, 96); ImageControl backgroundImage = new ImageControl(); backgroundImage.Style = "Image - Gallery Unselected Frame"; backgroundImage.Tiling = TextureMode.Stretch; backgroundImage.Dock = DockStyle.Fill; backgroundImage.NoEvents = true; ImageControl previewImage = new ImageControl(); previewImage.Tiling = TextureMode.Stretch; previewImage.Dock = DockStyle.Fill; previewImage.Margin = new Margin(1, 2, 1, 2); if (entry.GalleryItems.Count > 0) { Texture previewTexture = null;// entry.GalleryItems[0].GalleryPreview; if (previewTexture) { //previewImage.Texture = entry.GalleryItems[0].GalleryPreviewResourcePath; float scaleFactor; // Just assume we're always previewing the entire texture. Just need to figure out how big it should be: if (previewTexture.width > previewTexture.height) { scaleFactor = ((float)92) / previewTexture.width; } else { scaleFactor = ((float)92) / previewTexture.height; } previewImage.Size = new Point((int)(scaleFactor * previewTexture.width), (int)(scaleFactor * previewTexture.height)); } } previewImage.NoEvents = true; Button previewButton = new Button(); previewButton.Dock = DockStyle.Fill; previewButton.Style = "Inventory - Grid"; previewButton.Tint = ColorInt.ARGB(0.0f, 1.0f, 1.0f, 1.0f); Label label3D = new Label(); label3D.Dock = DockStyle.Fill; label3D.Text = "3D"; label3D.TextAlign = Alignment.MiddleCenter; label3D.Style = "Label - Blurb"; label3D.NoEvents = true; previewButton.MouseClick += (s, a) => { if (_3dPreviewScene) { GameObject.Destroy(_3dPreviewScene); } //_3dPreviewScene = (GameObject)GameObject.Instantiate(entry.Preview3D); (GuiHost.Renderer as UnityRenderer).InsertTexture(_3dPreviewTexture, "_3dPreviewTexture"); _galleryImage.Texture = "_3dPreviewTexture"; _galleryImage.TextureRect = new Rectangle(0, 0, _3dPreviewTexture.width, _3dPreviewTexture.height); }; navigatorFrame.Controls.Add(backgroundImage); navigatorFrame.Controls.Add(previewImage); navigatorFrame.Controls.Add(previewButton); navigatorFrame.Controls.Add(label3D); return(navigatorFrame); }
public void SetText(string text, Color color) { _text = text; _currentBackgroundColor = ColorInt.ARGB(color.a, color.r, color.g, color.b); SetText(); }
private Frame CreateNavigatorThumbnailButton(BiologEntryGalleryItem galleryItem) { Frame navigatorFrame = new Frame(); navigatorFrame.Dock = DockStyle.Left; navigatorFrame.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; navigatorFrame.Margin = new Margin(0, 0, 0, 0); navigatorFrame.NoEvents = true; navigatorFrame.Size = new Point(100, 96); ImageControl backgroundImage = new ImageControl(); //backgroundImage.Style = "Inventory - Grid";// "Image - Gallery Unselected Frame"; backgroundImage.Tiling = TextureMode.Stretch; backgroundImage.Dock = DockStyle.Fill; backgroundImage.NoEvents = true; ImageControl previewImage = new ImageControl(); previewImage.Tiling = TextureMode.Stretch; previewImage.Dock = DockStyle.Center; //previewImage.Margin = new Margin(4, 2, 4, 2); //previewImage.Texture = galleryItem.GalleryPreviewResourcePath; previewImage.NoEvents = true; Texture previewTexture = null;// galleryItem.GalleryPreview; if (previewTexture) { float scaleFactor; // Just assume we're always previewing the entire texture. Just need to figure out how big it should be: if (previewTexture.width > previewTexture.height) { scaleFactor = ((float)92) / previewTexture.width; } else { scaleFactor = ((float)92) / previewTexture.height; } previewImage.Size = new Point((int)(scaleFactor * previewTexture.width), (int)(scaleFactor * previewTexture.height)); } Button previewButton = new Button(); previewButton.Dock = DockStyle.Fill; previewButton.Style = "Inventory - Grid"; //"Image - Gallery Unselected Image"; previewButton.Tint = ColorInt.ARGB(0.0f, 1.0f, 1.0f, 1.0f); previewButton.MouseClick += (s, a) => { //Texture texture = galleryItem.GalleryImage; //_galleryImage.Texture = galleryItem.GalleryImageResourcePath; //_galleryImage.TextureRect = new Rectangle(0, 0, texture.width, texture.height); }; navigatorFrame.Controls.Add(backgroundImage); navigatorFrame.Controls.Add(previewImage); navigatorFrame.Controls.Add(previewButton); return(navigatorFrame); }