public idSimpleWindow(idWindow win) { _gui = win.UserInterface; _context = win.DeviceContext; _drawRect = win.DrawRectangle; _clientRect = win.ClientRectangle; _textRect = win.TextRectangle; _origin = win.Origin; _fontFamily = win.FontFamily; _name = win.Name; _materialScaleX = win.MaterialScaleX; _materialScaleY = win.MaterialScaleY; _borderSize = win.BorderSize; _textAlign = win.TextAlign; _textAlignX = win.TextAlignX; _textAlignY = win.TextAlignY; _background = win.Background; _flags = win.Flags; _textShadow = win.TextShadow; _visible.Set(win.IsVisible); _text.Set(win.Text); _rect.Set(win.Rectangle); _backColor.Set(win.BackColor); _materialColor.Set(win.MaterialColor); _foreColor.Set(win.ForeColor); _borderColor.Set(win.BorderColor); _textScale.Set(win.TextScale); _rotate.Set(win.Rotate); _shear.Set(win.Shear); _backgroundName.Set(win.BackgroundName); if(_backgroundName != string.Empty) { _background = idE.DeclManager.FindMaterial(_backgroundName); _background.Sort = (float) MaterialSort.Gui; ; _background.ImageClassification = 1; // just for resource tracking } _backgroundName.Material = _background; _parent = win.Parent; _hideCursor.Set(win.HideCursor); if(_parent != null) { if(_text.NeedsUpdate == true) { _parent.AddUpdateVariable(_text); } if(_visible.NeedsUpdate == true) { _parent.AddUpdateVariable(_visible); } if(_rect.NeedsUpdate == true) { _parent.AddUpdateVariable(_rect); } if(_backColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_backColor); } if(_materialColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_materialColor); } if(_foreColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_foreColor); } if(_borderColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_borderColor); } if(_textScale.NeedsUpdate == true) { _parent.AddUpdateVariable(_textScale); } if(_rotate.NeedsUpdate == true) { _parent.AddUpdateVariable(_rotate); } if(_shear.NeedsUpdate == true) { _parent.AddUpdateVariable(_shear); } if(_backgroundName.NeedsUpdate == true) { _parent.AddUpdateVariable(_backgroundName); } } }
private void Clear() { _initialized = false; _currentFont = null; _currentFontFamily = null; _mbcs = false; }
public void Init() { _scaleX = 0.0f; _whiteImage = idE.DeclManager.FindMaterial("guis/assets/white.tga"); _whiteImage.Sort = (float) MaterialSort.Gui; SetupFonts(); _matrix = Matrix.Identity; _origin = Vector3.Zero; _enableClipping = true; _mbcs = false; SetSize(idE.VirtualScreenWidth, idE.VirtualScreenHeight); _currentFontFamily = _fontFamilies[0]; /* * TODO*/ _cursorImages[(int) Cursor.Arrow] = idE.DeclManager.FindMaterial("ui/assets/guicursor_arrow.tga"); _cursorImages[(int) Cursor.Hand] = idE.DeclManager.FindMaterial("ui/assets/guicursor_hand.tga"); _cursorImages[(int) Cursor.Arrow].Sort = (float) MaterialSort.Gui; _cursorImages[(int) Cursor.Hand].Sort = (float) MaterialSort.Gui; /*scrollBarImages[SCROLLBAR_HBACK] = declManager->FindMaterial("ui/assets/scrollbarh.tga"); scrollBarImages[SCROLLBAR_VBACK] = declManager->FindMaterial("ui/assets/scrollbarv.tga"); scrollBarImages[SCROLLBAR_THUMB] = declManager->FindMaterial("ui/assets/scrollbar_thumb.tga"); scrollBarImages[SCROLLBAR_RIGHT] = declManager->FindMaterial("ui/assets/scrollbar_right.tga"); scrollBarImages[SCROLLBAR_LEFT] = declManager->FindMaterial("ui/assets/scrollbar_left.tga"); scrollBarImages[SCROLLBAR_UP] = declManager->FindMaterial("ui/assets/scrollbar_up.tga"); scrollBarImages[SCROLLBAR_DOWN] = declManager->FindMaterial("ui/assets/scrollbar_down.tga");*/ /*crollBarImages[SCROLLBAR_HBACK]->SetSort( SS_GUI ); scrollBarImages[SCROLLBAR_VBACK]->SetSort( SS_GUI ); scrollBarImages[SCROLLBAR_THUMB]->SetSort( SS_GUI ); scrollBarImages[SCROLLBAR_RIGHT]->SetSort( SS_GUI ); scrollBarImages[SCROLLBAR_LEFT]->SetSort( SS_GUI ); scrollBarImages[SCROLLBAR_UP]->SetSort( SS_GUI ); scrollBarImages[SCROLLBAR_DOWN]->SetSort( SS_GUI );*/ _cursor = Cursor.Arrow; /*overStrikeMode = true;*/ _initialized = true; }
private void Init() { _childID = 0; _flags = 0; _lastTimeRun = 0; _origin = Vector2.Zero; _fontFamily = null; _timeLine = -1; _offsetX = 0; _offsetY = 0; _cursor = Cursor.Arrow; _forceAspectWidth = 640; _forceAspectHeight = 480; _materialScaleX = 1; _materialScaleY = 1; _borderSize = 0; _textAlign = TextAlign.Left; _textAlignX = 0; _textAlignY = 0; _noEvents.Set(false); _noTime.Set(false); _visible.Set(true); _hideCursor.Set(false); _shear = Vector2.Zero; _rotate.Set(0); _textScale.Set(0.35f); _backColor.Set(Vector4.Zero); _foreColor.Set(new Vector4(1, 1, 1, 1)); _hoverColor.Set(new Vector4(1, 1, 1, 1)); _materialColor.Set(new Vector4(1, 1, 1, 1)); _borderColor.Set(Vector4.Zero); _background = null; _backgroundName.Set(string.Empty); _focusedChild = null; _captureChild = null; _overChild = null; // TODO /* */ _parent = null; /*saveOps = NULL; saveRegs = NULL;*/ _timeLine = -1; _textShadow = 0; _hover = false; int count = _scripts.Length; for(int i = 0; i < count; i++) { _scripts[i] = null; } }
protected virtual bool ParseInternalVariable(string name, idScriptParser parser) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } name = name.ToLower(); if(name == "bordersize") { _borderSize = parser.ParseFloat(); } else if(name == "comment") { _comment = ParseString(parser); } else if(name == "font") { string font = ParseString(parser); _fontFamily = _context.FindFont(font); } else if(name == "forceaspectwidth") { _forceAspectWidth = parser.ParseFloat(); } else if(name == "forceaspectheight") { _forceAspectHeight = parser.ParseFloat(); } else if(name == "invertrect") { if(parser.ParseBool() == true) { _flags |= WindowFlags.InvertRectangle; } } else if(name == "naturalmatscale") { if(parser.ParseBool() == true) { _flags |= WindowFlags.NaturalMaterial; } } else if(name == "noclip") { if(parser.ParseBool() == true) { _flags |= WindowFlags.NoClip; } } else if(name == "nocursor") { if(parser.ParseBool() == true) { _flags |= WindowFlags.NoCursor; } } else if(name == "nowrap") { if(parser.ParseBool() == true) { _flags |= WindowFlags.NoWrap; } } else if(name == "matscalex") { _materialScaleX = parser.ParseFloat(); } else if(name == "matscaley") { _materialScaleY = parser.ParseFloat(); } else if(name == "menugui") { if(parser.ParseBool() == true) { _flags |= WindowFlags.MenuInterface; } } else if(name == "modal") { if(parser.ParseBool() == true) { _flags |= WindowFlags.Modal; } } else if(name == "name") { _name = ParseString(parser); } else if(name == "play") { idConsole.Warning("play encountered during gui parse.. see robert"); string tmp = ParseString(parser); } else if(name == "shadow") { _textShadow = parser.ParseInteger(); } else if(name == "shear") { _shear.X = parser.ParseFloat(); idToken token = parser.ReadToken(); if(token.ToString() != ",") { parser.Error("Expected comma in shear definition"); return false; } _shear.Y = parser.ParseFloat(); } else if(name == "showcoords") { if(parser.ParseBool() == true) { _flags |= WindowFlags.ShowCoordinates; } } else if(name == "showtime") { if(parser.ParseBool() == true) { _flags |= WindowFlags.ShowTime; } } else if(name == "textalign") { _textAlign = (TextAlign) parser.ParseInteger(); } else if(name == "textalignx") { _textAlignX = parser.ParseFloat(); } else if(name == "textaligny") { _textAlignY = parser.ParseFloat(); } else if(name == "wantenter") { if(parser.ParseBool() == true) { _flags |= WindowFlags.WantEnter; } } else { return false; } return true; }
public idFontFamily RegisterFont(string fontName, string fileName) { float glyphScale; byte[] data; int pointSize; idFont outFont; idFontFamily fontFamily = new idFontFamily(fontName); string filePath; for(int fontCount = 0; fontCount < 3; fontCount++) { if(fontCount == 0) { pointSize = 12; } else if(fontCount == 1) { pointSize = 24; } else { pointSize = 48; } // we also need to adjust the scale based on point size relative to 48 points as the ui scaling is based on a 48 point font. // change the scale to be relative to 1 based on 72 dpi ( so dpi of 144 means a scale of .5 ) glyphScale = 1.0f; glyphScale *= 48.0f / pointSize; filePath = string.Format("{0}/fontImage_{1}.dat", fileName, pointSize); data = idE.FileSystem.ReadFile(filePath); if(data == null) { idConsole.Warning("RegisterFont: couldn't find font: {0}", fileName); return null; } using(BinaryReader r = new BinaryReader(new MemoryStream(data))) { outFont = new idFont(filePath); outFont.Init(r, fileName); if(fontCount == 0) { fontFamily.Small = outFont; } else if(fontCount == 1) { fontFamily.Medium = outFont; } else { fontFamily.Large = outFont; } } } return fontFamily; }