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