public void AddLine(string text) { int textHeight = console.GetVarInt(string.Format("{0}.profile.fontSize", this)) + console.GetVarInt(string.Format("{0}.lineSpacing", this)); if (textHeight <= 0) { textHeight = 12; } string scrollBox = getGroup(); //See if the two are eqaul, and if they are use the split instead of the getword. //int chatScrollHeight = Util.getWord(con.GetVarString(string.Format("{0}.extent", scrollBox)), 1).AsInt() - // 2 * con.GetVarInt(string.Format("{0}.profile.borderThickness", scrollBox)); int chatScrollHeight = console.GetVarString(string.Format("{0}.extent", scrollBox)).Split(' ')[1].AsInt() - 2 * console.GetVarInt(string.Format("{0}.profile.borderThickness", scrollBox)); int chatPosition = Util.getWord(console.GetVarString(string.Format("{0}.extent", this)), 1).AsInt() - chatScrollHeight + Util.getWord(console.GetVarString(string.Format("{0}.position", this)), 1).AsInt() - console.GetVarInt(string.Format("{0}.profile.borderThickness", scrollBox)); int linesToScroll = (int)Math.Floor(((chatPosition) / ((double)textHeight) + .5)); string origPosition = ""; if (linesToScroll > 0) { origPosition = console.GetVarString(string.Format("{0}.position", this)); } GuiButtonCtrl chatPageDown = "chatPageDown"; MessageVector HudMessageVector = "HudMessageVector"; //remove old messages from the top only if scrolled down all the way while (!chatPageDown.isVisible() && HudMessageVector.getNumLines() > 0 && HudMessageVector.getNumLines() >= iGlobal["$pref::HudMessageLogSize"]) { string tag = ((MessageVector)"HudMessageVector").getLineTag(0).AsString(); if (tag.AsInt() != 0) { tag.delete(); } ((MessageVector)"HudMessageVector").popFrontLine(); } //add the message... ((MessageVector)"HudMessageVector").pushBackLine(text, console.GetVarInt("$LastHudTarget")); console.SetVar("$LastHudTarget", 0); //now that we've added the message, see if we need to reset the position if (linesToScroll > 0) { ((GuiControl)"ChatPageDown").setVisible(true); console.SetVar(this + ".position", origPosition); } else { ((GuiControl)"ChatPageDown").setVisible(false); } }
public void disableAllButtons() { GuiButtonCtrl GetPosButton = this.FOT("GetPosButton"); GuiButtonCtrl GetRotButton = this.FOT("GetRotButton"); GuiButtonCtrl GetScaleButton = this.FOT("GetScaleButton"); GuiButtonCtrl GetSizeButton = this.FOT("GetSizeButton"); GuiButtonCtrl ApplyButton = this.FOT("ApplyButton"); GetPosButton.setActive(false); GetRotButton.setActive(false); GetScaleButton.setActive(false); GetSizeButton.setActive(false); ApplyButton.setActive(false); }
public override void onActivated() { base.onActivated(); EditorGui EditorGui = "EditorGui"; TerrainEditor ETerrainEditor = "ETerrainEditor"; GuiControl EWTerrainEditToolbar = "EWTerrainEditToolbar"; TerrainEditorPlugin TerrainEditorPlugin = "TerrainEditorPlugin"; EditorGui.EditorGuiStatusBar EditorGuiStatusBar = "EditorGuiStatusBar"; Settings EditorSettings = "EditorSettings"; EditorGui.readTerrainEditorSettings(); string action = EditorSettings.value("TerrainEditor/currentAction"); ETerrainEditor.switchAction(action); GuiButtonCtrl ctrl = (((GuiDynamicCtrlArrayControl)"ToolsPaletteArray").findObjectByInternalName(action, true)); ctrl.setStateOn(true); GuiBitmapButtonCtrl octrl = ((GuiControl)"EWTerrainEditToolbarBrushType").findObjectByInternalName("ellipse", true); octrl.performClick(); EditorGui.menuBar.insert(this["terrainMenu"], EditorGui.menuBar["dynamicItemInsertPos"].AsInt()); EditorGui.bringToFront(ETerrainEditor); ETerrainEditor.setVisible(true); ETerrainEditor.attachTerrain(); ETerrainEditor.makeFirstResponder(true); EWTerrainEditToolbar.setVisible(true); ETerrainEditor.onBrushChanged(); ETerrainEditor.setup(); TerrainEditorPlugin.syncBrushInfo(); EditorGuiStatusBar.setSelection(""); ((ActionMap)map).push(); }
public override void onWake() { EWorldEditor EWorldEditor = "EWorldEditor"; GuiCheckBoxCtrl PosRelative = this.FOT("PosRelative"); GuiCheckBoxCtrl RotRelative = this.FOT("RotRelative"); GuiCheckBoxCtrl ScaleRelative = this.FOT("ScaleRelative"); GuiCheckBoxCtrl SizeRelative = this.FOT("SizeRelative"); GuiButtonCtrl GetPosButton = this.FOT("GetPosButton"); GuiButtonCtrl GetRotButton = this.FOT("GetRotButton"); GuiButtonCtrl GetScaleButton = this.FOT("GetScaleButton"); GuiButtonCtrl GetSizeButton = this.FOT("GetSizeButton"); GuiCheckBoxCtrl SizeLocal = this.FOT("SizeLocal"); GuiTabBookCtrl ScaleTabBook = this.FOT("ScaleTabBook"); GuiButtonCtrl ApplyButton = this.FOT("ApplyButton"); // Make everything relative PosRelative.setStateOn(true); RotRelative.setStateOn(true); ScaleRelative.setStateOn(true); SizeRelative.setStateOn(false); GetPosButton.setActive(false); GetRotButton.setActive(false); GetScaleButton.setActive(false); GetSizeButton.setActive(false); // Size is always local SizeLocal.setStateOn(true); SizeLocal.setActive(false); ScaleTabBook.selectPage(0); // Scale page ApplyButton.setActive(false); EWorldEditor["ETransformSelectionDisplayed"] = false.AsString(); }
public void onSelectionChanged() { EWorldEditor EWorldEditor = "EWorldEditor"; GuiCheckBoxCtrl RotRelative = this.FOT("RotRelative"); GuiCheckBoxCtrl RotLocal = this.FOT("RotLocal"); GuiButtonCtrl GetPosButton = this.FOT("GetPosButton"); GuiButtonCtrl GetRotButton = this.FOT("GetRotButton"); GuiButtonCtrl GetScaleButton = this.FOT("GetScaleButton"); GuiButtonCtrl GetSizeButton = this.FOT("GetSizeButton"); GuiButtonCtrl ApplyButton = this.FOT("ApplyButton"); // Count the number of selected SceneObjects. There are // other object classes that could be selected, such // as SimGroups. int count = EWorldEditor.getSelectionSize(); int sceneObjects = 0; int globalBoundsObjects = 0; for (int i = 0; i < count; i++) { SimObject obj = EWorldEditor.getSelectedObject(i); if (obj.isMemberOfClass("SceneObject")) { sceneObjects++; if (obj.call("isGlobalBounds").AsBool()) { globalBoundsObjects++; } } } if (sceneObjects == 0) { // With nothing selected, disable all Get buttons this.disableAllButtons(); } else if (sceneObjects == 1) { // With one selected, all Get buttons are active GetPosButton.setActive(true); GetRotButton.setActive(true); // Special case for Scale and Size for global bounds objects if (globalBoundsObjects == 1) { GetSizeButton.setActive(false); GetScaleButton.setActive(false); } else { GetSizeButton.setActive(true); GetScaleButton.setActive(true); } ApplyButton.setActive(true); } else { // With more than one selected, only the position button // is active GetPosButton.setActive(true); GetRotButton.setActive(false); GetScaleButton.setActive(false); GetSizeButton.setActive(false); ApplyButton.setActive(true); // If both RotRelative and RotLocal are unchecked, then go with RotLocal if (RotRelative.getValue().AsInt() == 0 && RotLocal.getValue().AsInt() == 0) { RotLocal.setStateOn(true); } } }