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 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 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)); } }