public static void TerrainImportGui_TerrainMaterialApplyCallback(string mat, string matIndex) { // Skip over a bad selection. if (!mat.isObject()) { return; } GuiTextListCtrl opacityList = ((GuiControl)"TerrainImportGui").findObjectByInternalName("OpacityLayerTextList", true); string itemIdx = ((SimObject)"TerrainImportGui")["activeIdx"]; if (itemIdx.AsInt() < 0 || itemIdx == "") { return; } string rowTxt = opacityList.getRowTextById(itemIdx.AsInt()); int columTxtCount = omni.Util.getFieldCount(rowTxt); if (columTxtCount > 2) { rowTxt = omni.Util.getFields(rowTxt, 0, 1); } opacityList.setRowById(itemIdx.AsInt(), rowTxt + "\t" + ((SimObject)mat).internalName + "/t" + mat); }
public static void StartLevel(string mission, string hostingType) { GuiTextListCtrl CL_levelList = "CL_levelList"; if (mission == "") { mission = omni.Util.getField(CL_levelList.getRowTextById(CL_levelList.getSelectedId()), 1); } string serverType = hostingType; if (serverType == "") { if (omni.bGlobal["$pref::HostMultiPlayer"]) { serverType = "MultiPlayer"; } else { serverType = "SinglePlayer"; } } // Show the loading screen immediately. if ("LoadingGui".isObject()) { ((GuiCanvas)"Canvas").setContent("LoadingGui"); ((GuiProgressBitmapCtrl)"LoadingProgress").setValue("1"); ((GuiTextCtrl)"LoadingProgressTxt").setValue("LOADING MISSION FILE"); ((GuiCanvas)"Canvas").repaint(-1); } server.createAndConnectToLocalServer(serverType, mission); }
public static void StartSelectedDemo() { // first unit is filename GuiTextListCtrl RecordingsDlgList = "RecordingsDlgList"; int sel = RecordingsDlgList.getSelectedId(); string rowText = RecordingsDlgList.getRowTextById(sel); string file = omni.sGlobal["$currentMod"] + "/recordings/" + omni.Util.getField(rowText, 0) + ".rec"; GameConnection ServerConnection = new ObjectCreator("GameConnection", "ServerConnection").Create(); ((SimGroup)"RootGroup").add(ServerConnection); // Start up important client-side stuff, such as the group // for particle emitters. This doesn't get launched during a demo // as we short circuit the whole mission loading sequence. mission.clientStartMission(); if (ServerConnection.playDemo(file)) { ((GuiCanvas)"canvas").setContent("PlayGui"); ((GuiCanvas)"canvas").popDialog("RecordingsDlg"); ServerConnection.call("prepDemoPlayback"); } else { messageBox.MessageBoxOK("Playback Failed", "Demo playback failed for file '" + file + "'.", ""); if ("ServerConnection".isObject()) { "ServerConnection".delete(); } } }
public static void DbgWatchDialogEdit() { GuiTextEditCtrl EditWatchDialogValue = "EditWatchDialogValue"; GuiTextListCtrl DebuggerWatchView = "DebuggerWatchView"; DebuggerEditWatchDlg DebuggerEditWatchDlg = "DebuggerEditWatchDlg"; TCPDebugger TCPDebugger = "TCPDebugger"; GuiCanvas Canvas = "Canvas"; string newValue = EditWatchDialogValue.getValue(); int id = DebuggerWatchView.getSelectedId(); if (id >= 0) { string row = DebuggerWatchView.getRowTextById(id); string expr = omni.Util.getField(row, 0); string assignment; if (newValue == "") { assignment = expr + " = \"\""; } else { assignment = expr + " = " + newValue; } TCPDebugger.send("EVAL " + id + " 0 " + assignment + "\r\n"); } Canvas.popDialog(DebuggerEditWatchDlg); }
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 updateScore(GameConnection clientId, int score, int kills, int deaths) { GuiTextListCtrl PlayerListGuiList = "PlayerListGuiList"; string text = PlayerListGuiList.getRowTextById(clientId); //Since I'm lazy and I don't feel like writing a csharp function... text = Util.setField(text, 1, score.AsString()); text = Util.setField(text, 2, kills.AsString()); text = Util.setField(text, 3, deaths.AsString()); PlayerListGuiList.setRowById(clientId, text); // Sorts by score PlayerListGuiList.sortNumerical(1, false); 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 onOpacityListDblClick() { GuiTextListCtrl opacityList = ((GuiControl)"TerrainImportGui").findObjectByInternalName("OpacityLayerTextList", true); int itemIdx = opacityList.getSelectedId(); if (itemIdx < 0) { return; } this["activeIdx"] = itemIdx.AsString(); string rowTxt = opacityList.getRowTextById(itemIdx); string matTxt = Util.getField(rowTxt, 2); string matID = Util.getField(rowTxt, 3); "TerrainMaterialDlg".call("showByObjectId", new string[] { matID, "TerrainImportGui_TerrainMaterialApplyCallback" }); }
public static void StartGame(string mission = null, string hostingType = null) { if (string.IsNullOrEmpty(mission)) { GuiTextListCtrl CL_levelList = Sim.FindObject <GuiTextListCtrl>("CL_levelList"); int id = CL_levelList.getSelectedId(); mission = Global.getField(CL_levelList.getRowTextById(id), 1); // Alternatively: //error("Cannot start a level with no level selected!"); } string serverType = hostingType; if (string.IsNullOrEmpty(hostingType)) { if (Globals.GetBool("pref::HostMultiPlayer")) { serverType = "MultiPlayer"; } else { serverType = "SinglePlayer"; } } // Show the loading screen immediately. if (Global.isObject("LoadingGui")) { Core.Canvas.GameCanvas.setContent("LoadingGui"); GuiProgressBitmapCtrl LoadingProgress = Sim.FindObject <GuiProgressBitmapCtrl>("LoadingProgress"); GuiTextCtrl LoadingProgressTxt = Sim.FindObject <GuiTextCtrl>("LoadingProgressTxt"); LoadingProgress.setValue("1"); LoadingProgressTxt.setValue("LOADING MISSION FILE"); Core.Canvas.GameCanvas.repaint(); } Server.Server.createAndConnectToLocalServer(serverType, mission); }
public void handleEvalOut(string line) { GuiTextCtrl DebuggerCursorWatch = "DebuggerCursorWatch"; GuiTextListCtrl DebuggerWatchView = "DebuggerWatchView"; int id = Util.firstWord(line).AsInt(); string value = Util.restWords(line); // See if it's the cursor watch, or from the watch window. if (id < 0) { DebuggerCursorWatch.setText(DebuggerCursorWatch["expr"] + ' ' + "=" + ' ' + value); } else { string row = DebuggerWatchView.getRowTextById(id); if (row == "") { return; } string expr = Util.getField(row, 0); DebuggerWatchView.setRowById(id, expr + "\t" + value); } }
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"); } }