//////////////////////////////////////////////////////////// // File: CmdView.cs 1.4Beta // Author: Runar/Freaky // Credits: Freaky, and Coca-Cola for keeping me awake.. // Info: Places a mini-commander on your screen. // // History: 1.4 Added autoposition for 1024x768 and 800x600. // // 1.3 Totally new approach, ONLY use the PlayGui. // Features BOTH the normal and the mini commander. // Now this of course also has some drawbacks: // // -Will NOT work on bad connections, if you have // problems changing weapons or fireing, just // toggle the cmdview off. This is feature is NOT // for HPB's, sorry about that. // -MUST replace the original commander button. // -You need to open the commander once to get the // guis in place after a new mission has been // started. // -Pressing "c" (the commander key) will cause a // slight delay or lag before and after accessing // the original commander. // -You need to toggle the CmdView ON after every // death/inventory/objective screen. // -Messes up the tab-menu a bit, Toggle CmdView // off before looking at tab-menu. Or if you // already pressed Tab and cant close it, just // close the CmdView and Tab again. // -If something crashes, you may end up with a // broken PlayGui, in that case just delete // Tribes\Config\play.gui. Should not be very // likely to happen now though. // -Still does NOT work on BWadmin servers :\ // Really need to talk to Wizard or poker. // //////////////////////////////////////////////////////////// // Do we want the sensor range visible? $CmdView::mapsensorrange = "True"; // Do we want the sensor range translucent? $CmdView::mapSensorTranslucent = "TRUE"; // Do we want object names on the map? $CmdView::mapnames = "FALSE"; // Commander Map Filter, default "1" // Bit 0 = Show Players // Bit 1 = Show Turrets // Bit 2 = Show Items // Bit 3 = Show Objects // $CmdView::mapFilter = "1"; // This may need to be raised for HPB's $CmdView::Delay = "0.3"; // Need this.. $CmdView::Active = "False"; $CmdView::Exist = "False"; //Keybinds // DONT TOUCH THIS LINE editActionMap("actionMap.sae"); bindCommand(Keyboard0, make, "backspace", TO, "CmdView::CommandMode();"); bindCommand(keyboard0, break, "backspace", TO, ""); // Replace the normal Commander key, re-bind the original in 'Options' bindCommand(Keyboard0, make, "c", TO, "CmdView::Change();"); bindCommand(Keyboard0, break, "c", TO, ""); // Attach our events Event::Attach(EventYouSpawned, CmdView::TogOn); Event::Attach(EventStationOff, CmdView::TogOn); Event::Attach(eventPlayGUICreated, CmdView::Create); Event::Attach(eventGuiOpen, CmdView::onGuiOpen); Event::Attach(eventExit, CmdView::Destroy); //toggle on after inv use function CmdView::TogOn() { if ($CmdView::status) { schedule("CmdView::CommandMode();", 0.5); } } // Decide what position to use if($pref::VideoFullScreenRes == "1024x768") { // Size and Position for 1024x768 $CmdView::Width = 200; $CmdView::Height = 200; $CmdView::Xpos = 778; $CmdView::Ypos = 523; } else { // Size and Position for 800x600 $CmdView::Width = 200; $CmdView::Height = 180; $CmdView::Xpos = 0; $CmdView::Ypos = 420; } function CmdView::Create() { // Make sure we dont make 2 if($CmdView::Exist) return; // Delete old objects CmdView::Destroy(); // Delete the entire CommandGui if(isObject(CommandGui)) deleteobject(CommandGui); // Here's the main container %hudContainer=newObject("CmdView_Container", SimGui::Control, $CmdView::Xpos, $CmdView::Ypos, $CmdView::Width, $CmdView::Height); // Heres the background %mapbg = newObject("CmdView_BG", FearGui::FearGuiMenu, 0, 0, $CmdView::Width, $CmdView::Height); // Create the new CommanderMap object TS_140201 IDCTG_CMD_TS %mapgui = newobject("CmdView_Gui", Feargui::TScommander, 3, 2, $CmdView::Width-6, $CmdView::Height-4); // Add our controls to the container addToSet("CmdView_Container", %mapbg); addToSet("CmdView_Container", %mapgui); // Add the whole container to PlayGui addToSet(PlayGui, %hudContainer); // Init our map prefs $pref::mapsensorrange = $CmdView::mapsensorrange; $pref::mapSensorTranslucent = $CmdView::mapSensorTranslucent; $pref::mapnames = $CmdView::mapnames; $pref::mapfilter = $CmdView::mapfilter; // Re-build the commandermap rebuildcommandmap(); // Re-size and re-position CmdView::Resize(); Control::SetPosition(CmdView_Container, $CmdView::Xpos, $CmdView::Ypos); // We don't want it visible yet Control::setVisible(CmdView_Container, "False"); // Now the objects are there $CmdView::Exist = "True"; return; } // Triggered onGuiOpen function CmdView::onGuiOpen(%gui) { if(%gui == "playGui") CmdView::PlayMode(); return; } // This is our Toggle Off function function CmdView::PlayMode() { // if($CmdView::Exist != "True") // return; // Make it un-visible Control::setVisible(CmdView_Container, "False"); // Go to playmode remoteEval(2048, PlayMode); // CmdView is NOT active now $CmdView::Active = "False"; return; } // This is our Toggle On function function CmdView::CommandMode() { // if($CmdView::Exist != "True") // return; // Make it visible Control::setVisible(CmdView_Container, True); // Go to CommandMode remoteEval(2048, CommandMode); // Force full bandwidth RemoteEval(2048, "scom", -1); // Turn off the cursor Schedule("CursorOff(mainwindow);", $CmdView::Delay); // CmdView IS active now $CmdView::Active = "True"; return; } // The actual toggle function function CmdView::Toggle() { if($CmdView::Active) { // Go to PlayMode $CmdView::status=false; CmdView::PlayMode(); } else { // Go to CommandMode $CmdView::status=true; CmdView::CommandMode(); } return; } // The function to switch between large/small commander function CmdView::Change() { if($CmdView::Exist) { // Recreate Commander CmdView::Restore(); // Go to CommandMode schedule("remoteEval(2048, CommandMode);", 0.5); } else { // Go to playmode remoteEval(2048, PlayMode); // Create CmdView schedule("CmdView::Create();", 0.5); } return; } // Re-size and re-position totally strange that I need this at all.. function CmdView::Resize() { Control::SetPosition("CmdView_Gui", 3, 2); Control::SetExtent("CmdView_Gui", $CmdView::Width-6, $CmdView::Height-4); return; } // Restore Original Commander function CmdView::Restore() { // Delete all traces of CmdView CmdView::Destroy(); // Load a brand new CommandGui if(!isObject(CommandGui)) loadObject("CommandGui", "gui\\command.gui"); // Re-build the commandermap schedule("rebuildcommandmap();", 0.5); return; } // Delete all "CmdView_*" objects function CmdView::Destroy() { // Delete all objects HUD::Destroy("CmdView_"); // Now the objects are gone $CmdView::Exist = "False"; return; } $Viking::CmdView = "TRUE"; //useful...add to support when packaging function HUD::Destroy(%hudstring) { %ngs = nameToId(NamedGuiSet); %len = Group::objectCount(%ngs); for(%i = 0; %i < %len; %i++) { %obj = Group::getObject(%ngs, %i); %objectName=Object::getName(%obj); if(String::findSubStr(%objectname, %hudstring) != -1 ) deleteObject(%obj); } return; }