public void addMissionFile(string file) { string levelName = Util.fileBase(file); string levelDesc = "A Torque Level"; string _LevelInfoObject = getLevelInfo(file); if (_LevelInfoObject != "0") { ScriptObject LevelInfoObject = _LevelInfoObject; if (LevelInfoObject["levelName"] != "") { levelName = LevelInfoObject["levelName"]; } else if (LevelInfoObject["name"] != "") { levelName = LevelInfoObject["name"]; } if (LevelInfoObject["desc0"] != "") { levelDesc = LevelInfoObject["desc0"]; } LevelInfoObject.delete(); } GuiTextListCtrl CL_levelList = "CL_levelList"; CL_levelList.addRow(CL_levelList.rowCount(), levelName + "\t" + file + "\t" + levelDesc, -1); }
public static void ClientCmdGameEnd(string endgamepause) { audio.sfxStopAll(""); if (GuiCanvas.EditorIsActive() || GuiCanvas.GuiEditorIsActive()) { return; } // Copy the current scores from the player list into the // end game gui (bit of a hack for now). GuiTextListCtrl EndGameGuiList = "EndGameGuiList"; EndGameGuiList.clear(); GuiTextListCtrl PlayerListGuiList = "PlayerListGuiList"; for (int i = 0; i < PlayerListGuiList.rowCount(); i++) { string text = PlayerListGuiList.getRowText(i); string id = PlayerListGuiList.getRowId(i).AsString(); EndGameGuiList.addRow(id.AsInt(), text, -1); } EndGameGuiList.sortNumerical(1, false); ((GuiCanvas)"Canvas").setContent("EndGameGui"); if (endgamepause.AsInt() > 0) { omni.Util._schedule((endgamepause.AsInt() * 1000).AsString(), "0", "ShowLoading"); } }
public static void TerrainImportGuiAddOpacityMap(string name) { // TODO: Need to actually look at // the file here and figure // out how many channels it has. string txt = omni.Util.makeRelativePath(name, omni.Util.getWorkingDirectory()); // Will need to do this stuff // once per channel in the file // currently it works with just grayscale. string channelsTxt = "R\tG\tB\tA"; string bitmapInfo = omni.Util.getBitmapInfo(name); string channelCount = omni.Util.getWord(bitmapInfo, 2); GuiTextListCtrl opacityList = ((GuiControl)"TerrainImportGui").findObjectByInternalName("OpacityLayerTextList", true); guiTerrainImportGui TerrainImportGui = "TerrainImportGui"; ArrayObject namesArray = TerrainImportGui["namesArray"]; ArrayObject channelsArray = TerrainImportGui["channelsArray"]; for (int i = 0; i < channelCount.AsInt(); i++) { namesArray.push_back(txt, name); channelsArray.push_back(txt, omni.Util.getWord(channelsTxt, i) + "/t" + channelCount); //TerrainImportGui.namesArray.echo(); int count = opacityList.rowCount(); opacityList.addRow(count, txt + "/t" + omni.Util.getWord(channelsTxt, i), -1); } //OpacityMapListBox.addItem( %name ); }
public static void DbgRefreshWatches() { GuiTextListCtrl DebuggerWatchView = "DebuggerWatchView"; TCPDebugger TCPDebugger = "TCPDebugger"; for (int i = 0; i < DebuggerWatchView.rowCount(); i++) { int id = DebuggerWatchView.getRowId(i); string row = DebuggerWatchView.getRowTextById(id); string expr = omni.Util.getField(row, 0); TCPDebugger.send("EVAL " + id + " 0 " + expr + "\r\n"); } }
public virtual void zeroScores() { GuiTextListCtrl PlayerListGuiList = "PlayerListGuiList"; for (int i = 0; i < PlayerListGuiList.rowCount(); i++) { string text = PlayerListGuiList.getRowText(i); text = Util.setField(text, 1, "0"); text = Util.setField(text, 2, "0"); text = Util.setField(text, 3, "0"); PlayerListGuiList.setRowById(PlayerListGuiList.getRowId(i), text); } PlayerListGuiList.clearSelection(); }
public void handleBreak(string line) { GuiTextCtrl DebuggerStatus = "DebuggerStatus"; GuiTextListCtrl DebuggerWatchView = "DebuggerWatchView"; DebuggerCallStack DebuggerCallStack = "DebuggerCallStack"; DebuggerStatus.setValue("BREAK"); // Query all the watches. for (int i = 0; i < DebuggerWatchView.rowCount(); i++) { int id = DebuggerWatchView.getRowId(i); string row = DebuggerWatchView.getRowTextById(id); string expr = Util.getField(row, 0); this.send("EVAL " + id + " 0 " + expr + "\r\n"); } // Update the call stack window. DebuggerCallStack.clear(); string file = Util.getWord(line, 0); string lineNumber = Util.getWord(line, 1); string funcName = Util.getWord(line, 2); DbgOpenFile(file, lineNumber.AsInt(), true); int nextWord = 3; //int rowId = 0; int iD = 0; while (true) { DebuggerCallStack.setRowById(iD, file + "\t" + lineNumber + "\t" + funcName); iD++; file = Util.getWord(line, nextWord); lineNumber = Util.getWord(line, nextWord + 1); funcName = Util.getWord(line, nextWord + 2); nextWord += 3; if (file == "") { break; } } }
public void update() { // Copy the servers into the server list. ((GuiWindowCtrl)"JS_queryStatus").setVisible(false); GuiTextListCtrl JS_serverList = "JS_serverList"; JS_serverList.clear(); int sc = Util.getServerCount(); for (int i = 0; i < sc; i++) { Util.setServerInfo((uint)i); JS_serverList.addRow(i, sGlobal["$ServerInfo::Name"] + '\t' + sGlobal["$ServerInfo::Ping"] + "\t" + sGlobal["$ServerInfo::PlayerCount"] + "/" + sGlobal["$ServerInfo::MaxPlayers"] + "/t" + sGlobal["$ServerInfo::Version"] + "\t" + sGlobal["$ServerInfo::MissionName"], -1); } JS_serverList.sort("0"); JS_serverList.setSelectedRow(0); JS_serverList.scrollVisible(0); ((GuiButtonCtrl)"JS_joinServer").setActive(JS_serverList.rowCount() > 0); }
public override void onWake() { GuiTextListCtrl CL_levelList = "CL_levelList"; CL_levelList.clear(); ChooseLevelWindow ChooseLevelWindow = "ChooseLevelWindow"; GuiDynamicCtrlArrayControl SmallPreviews = ((GuiDynamicCtrlArrayControl)((GuiWindowCtrl)"ChooseLevelWindow").findObjectByInternalName("SmallPreviews", false)); ((GuiDynamicCtrlArrayControl)ChooseLevelWindow.findObjectByInternalName("SmallPreviews", false)).clear(); string file = ""; for (file = Util.findFirstFile(sGlobal["$Server::MissionFileSpec"], true); file != ""; file = Util.findNextFile(sGlobal["$Server::MissionFileSpec"])) { // Skip our new level/mission if we arent choosing a level // to launch in the editor. if (!this["launchInEditor"].AsBool()) { if (Util.strstr(file, "newMission.mis") > -1) { continue; } if (Util.strstr(file, "newLevel.mis") > -1) { continue; } } addMissionFile(file); } // Also add the new level mission as defined in the world editor settings // if we are choosing a level to launch in the editor. if (this["launchInEditor"].AsBool()) { file = ((Settings)"EditorSettings").value("WorldEditor/newLevelFile"); if (file != "") { addMissionFile(file); } } // Sort our list CL_levelList.sort("0"); // Set the first row as the selected row CL_levelList.setSelectedRow(0); GuiBitmapButtonCtrl preview; for (int i = 0; i < CL_levelList.rowCount(); i++) { ObjectCreator oc = new ObjectCreator("GuiBitmapButtonCtrl"); oc["internalName"] = "SmallPreview" + i; oc["Extent"] = "108 81"; oc["bitmap"] = "art/gui/no-preview"; oc["command"] = "ChooseLevelWindow.previewSelected(ChooseLevelWindow->SmallPreviews->SmallPreview" + i + ");"; preview = oc.Create(); SmallPreviews.add(preview); // Set this small preview visible if (i > 5) { preview.setVisible(false); } // Set the level index preview["levelIndex"] = i.AsString(); // Get the name string name = Util.getField(CL_levelList.getRowText(i), 0); preview["levelName"] = name; file = Util.getField(CL_levelList.getRowText(i), 1); // Find the preview image string levelPreview = Util.filePath(file) + "/" + Util.fileBase(file) + "_preview"; // Test against all of the different image formats // This should probably be moved into an engine function if (Util.isFile(levelPreview + ".png") || Util.isFile(levelPreview + ".jpg") || Util.isFile(levelPreview + ".bmp") || Util.isFile(levelPreview + ".gif") || Util.isFile(levelPreview + ".jng") || Util.isFile(levelPreview + ".mng") || Util.isFile(levelPreview + ".tga")) { preview.setBitmap(levelPreview); } // Get the description String desc = Util.getField(CL_levelList.getRowText(i), 2); preview["levelDesc"] = desc; } SmallPreviews["firstVisible"] = "-1"; SmallPreviews["lastVisible"] = "-1"; if (SmallPreviews.getCount() > 0) { SmallPreviews["firstVisible"] = "0"; if (SmallPreviews.getCount() < 6) { SmallPreviews["lastVisible"] = (SmallPreviews.getCount() - 1).AsString(); } else { SmallPreviews["lastVisible"] = "4"; } } if (SmallPreviews.getCount() > 0) { ChooseLevelWindow.previewSelected(SmallPreviews.getObject(0)); } // If we have 5 or less previews then hide our next/previous buttons // and resize to fill their positions if (SmallPreviews.getCount() < 6) { ((GuiBitmapButtonCtrl)ChooseLevelWindow.findObjectByInternalName("PreviousSmallPreviews", false)).setVisible(false); ((GuiBitmapButtonCtrl)ChooseLevelWindow.findObjectByInternalName("NextSmallPreviews", false)).setVisible(false); Point2I previewPos = SmallPreviews.getPosition(); Point2I previousPos = ((GuiBitmapButtonCtrl)ChooseLevelWindow.findObjectByInternalName("PreviousSmallPreviews", false)).getPosition(); SmallPreviews.setPosition(previousPos.x, previewPos.y); SmallPreviews.colSpacing = 10; SmallPreviews.refresh(); } if (SmallPreviews.getCount() <= 1) { // Hide the small previews SmallPreviews.setVisible(false); // Shrink the ChooseLevelWindow so that we don't have a large blank space ChooseLevelWindow.setExtent(new Point2F(ChooseLevelWindow.getExtent().x + " " + SmallPreviews.getPosition().y)); ChooseLevelWindow.setExtent(new Point2F(ChooseLevelWindow.getExtent().x, SmallPreviews.getPosition().y)); } else { // Make sure the small previews are visible SmallPreviews.setVisible(true); int extentX = ChooseLevelWindow.getExtent().x; int extentY = SmallPreviews.getPosition().y; extentY = extentY + SmallPreviews.getExtent().y; extentY += 9; ChooseLevelWindow.setExtent(new Point2F(extentX, extentY)); } }
public void import() { // Gather all the import settings. GuiTextEditCtrl HeightfieldFilename = this.findObjectByInternalName("HeightfieldFilename", true); string heightMapPng = HeightfieldFilename.getText(); GuiTextEditCtrl MetersPerPixel = this.findObjectByInternalName("MetersPerPixel", true); string metersPerPixel = MetersPerPixel.getText(); GuiTextEditCtrl HeightScale = findObjectByInternalName("HeightScale", true); string heightScale = HeightScale.getText(); GuiCheckBoxCtrl FlipYAxis = findObjectByInternalName("FlipYAxis", true); bool flipYAxis = FlipYAxis.isStateOn(); editor Editor = "Editor"; // Grab and validate terrain object name. string terrainName = ((GuiTextEditCtrl)this.findObjectByInternalName("TerrainName", true)).getText(); if (!terrainName.isObject() && ((SimObject)terrainName).isMemberOfClass("TerrainBlock") && !Editor.validateObjectName(terrainName, false)) { return; } string opacityNames = ""; string materialNames = ""; GuiTextListCtrl opacityList = this.findObjectByInternalName("OpacityLayerTextList", true); ArrayObject namesArray = this["namesArray"]; ArrayObject channelsArray = this["channelsArray"]; for (int i = 0; i < opacityList.rowCount(); i++) { string itemText = opacityList.getRowTextById(i); string opacityName = namesArray.getValue(i); string channelInfo = channelsArray.getValue(i); string channel = Util.getWord(channelInfo, 0); string materialName = Util.getField(itemText, 2); opacityNames += opacityName + "\t" + channel + "\n"; materialNames += materialName + "\n"; } int updated = Util.nameToID(terrainName); // This will update an existing terrain with the name %terrainName, // or create a new one if %terrainName isn't a TerrainBlock String obj = console.Call_Classname("TerrainBlock", "import", new string[] { terrainName, heightMapPng, metersPerPixel, heightScale, opacityNames, materialNames, flipYAxis.AsString() }); ((GuiCanvas)"Canvas").popDialog(this); if (obj.isObject()) { if (obj != updated.AsString()) { // created a new TerrainBlock // Submit an undo action. Extendable.MECreateUndoAction.submit(obj); } EWorldEditor EWorldEditor = "EWorldEditor"; if (!EWorldEditor.isObject()) { throw new Exception("ObjectBuilderGui::processNewObject - EWorldEditor is missing!"); } // Select it in the editor. EWorldEditor.clearSelection(); EWorldEditor.selectObject(obj); // When we drop the selection don't store undo // state for it... the creation deals with it. EWorldEditor.dropSelection(obj.AsBool()); EWorldEditor.isDirty = true; //Copyright Winterleaf Entertainment L.L.C. 2013 ((TerrainPainter)"TerrainPainter").updateLayers(""); //Copyright Winterleaf Entertainment L.L.C. 2013 } else { messageBox.MessageBoxOK("Import Terrain", "Terrain import failed! Check console for error messages.", "Ok"); } }