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 setViewTypeCategorized() { GuiEditorGui.GuiEditor GuiEditor = "GuiEditor"; // Create rollouts for each class category we have and // record the classes in each category in a temporary array // on the rollout so we can later sort the class names before // creating the actual controls in the toolbox. string controls = Util.enumerateConsoleClassesByCategory("Gui"); foreach (string className in controls.Split('\t')) { if (GuiEditor.isFilteredClass(className) || !Util.isMemberOfClass(className, "GuiControl")) { continue; } // Get the class's next category under Gui. string category = Util.getWord(Util.getCategoryOfClass(className), 1); if (category == "") { continue; } // Find or create the rollout for the category. GuiRolloutCtrl rollout = this.getOrCreateRolloutForCategory(category); // Insert the item. if (!rollout["classes"].AsBool()) { rollout["classes"] = new ObjectCreator("ArrayObject").Create().AsString(); } ((ArrayObject)rollout["classes"]).push_back(className, ""); } // Go through the rollouts, sort the class names, and // create the toolbox controls. for (uint i = 0; i < this.getCount(); i++) { GuiRolloutCtrl rollout = this.getObject(i); if (!rollout.isMemberOfClass("GuiRolloutCtrl")) { continue; } // Get the array with the class names and sort it. // Sort in descending order to counter reversal of order // when we later add the controls to the stack. ArrayObject classes = rollout["classes"]; classes.sortk(true); // Add a control for each of the classes to the // rollout's stack control. GuiDynamicCtrlArrayControl stack = rollout.FOT("array"); int numClasses = classes.count(); for (int n = 0; n < numClasses; n++) { string className = classes.getKey(n); #region GuiIconButtonCtrl () oc_Newobject3 ObjectCreator oc_Newobject3 = new ObjectCreator("GuiIconButtonCtrl", "", typeof(GuiEditorToolboxButton)); oc_Newobject3["profile"] = "ToolsGuiIconButtonSmallProfile"; oc_Newobject3["extent"] = "128 18"; oc_Newobject3["text"] = className; oc_Newobject3["iconBitmap"] = console.Call_Classname("EditorIconRegistry", "findIconByClassName", new string[] { className }); oc_Newobject3["buttonMargin"] = "2 2"; oc_Newobject3["iconLocation"] = "left"; oc_Newobject3["textLocation"] = "left"; oc_Newobject3["textMargin"] = "24"; oc_Newobject3["AutoSize"] = new ObjectCreator.StringNoQuote("true"); oc_Newobject3["command"] = "GuiEditor.createControl( " + className + " );"; oc_Newobject3["useMouseEvents"] = new ObjectCreator.StringNoQuote("true"); //TODO doesn't work for every control. //oc_Newobject3["tooltip"] = className + '\n' + "\n" + Util.getDescriptionOfClass( className ); oc_Newobject3["tooltipProfile"] = "ToolsGuiToolTipProfile"; #endregion GuiIconButtonCtrl ctrl = oc_Newobject3.Create(); stack.add(ctrl); } // Delete the temporary array. rollout["classes"] = ""; classes.delete(); } this.currentViewType = "Categorized"; }