Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Sel = 0;
- $InvHud::MaxLoadouts = 20;
- $InvHud::Lists = new SimGroup();
- if(isFile("legions/preferences/MyLoadouts.cs"))
- exec("legions/preferences/MyLoadouts.cs");
- addMessageCallback("InvHudListClear", handleInvHudListClear);
- function handleInvHudListClear()
- {
- $InvHud::Lists.delete();
- $InvHud::Lists = new SimGroup();
- }
- addMessageCallback("InvHudListAdd", handleInvHudListAdd);
- function handleInvHudListAdd(%msgType, %listType, %dataBlock, %name, %maxInvCount,%description)
- {
- if(!isObject(%listType))
- {
- %newList = new SimSet(%listType);
- $InvHud::Lists.add(%newList);
- }
- %newItem = new ScriptObject()
- {
- name = %name;
- dataBlock = %dataBlock;
- maxInvCount = %maxInvCount;
- //description = %description;
- };
- $itemDescription[%name] = %description;
- $InvHud::ListNTID[%name] = %newItem;
- %listType.add(%newItem);
- }
- addMessageCallback("InvHudListDone", updateInvHudLoadout);
- addMessageCallback("InvHudListInvalid", handleInvHudListInvalid);
- function handleInvHudListInvalid(%msgType, %listType, %dataBlock)
- {
- switch$ (%listType)
- {
- case "InvHudListWeapon":
- %dataBlock++;
- $Pref::InvHud::CurWep[%dataBlock] = "";
- %obj = "InvHudWeapon" @ %dataBlock;
- %obj.setText("N/A");
- case "InvHudListClass":
- $Pref::InvHud::CurClass = "";
- InvHudClass.setText("N/A");
- case "InvHudListOffhand":
- $Pref::InvHud::CurOffhand = "";
- InvHudOffhand.setText("N/A");
- case "InvHudListCore":
- $Pref::InvHud::CurCore = "";
- InvHudCore.setText("N/A");
- }
- }
- function toggleInvHud(%val)
- {
- if(%val)
- {
- if(InvHud.isAwake())
- {
- InvHud.close();
- }
- else
- {
- if(GamePanel.isAwake()) GamePanel.close();
- if(SpawnSelect.isAwake()) SpawnSelect.close();
- InvHud.open();
- }
- }
- }
- function InvHud::open(%this)
- {
- Canvas.pushDialog(InvHud);
- slideElement(LoadoutBG, -603, 0, 0, 0, 250);
- }
- function InvHud::close(%this)
- {
- if(InvHudLargeModelPreview.isVisible())
- InvHudLargeModelPreview.setVisible(false);
- slideElement(LoadoutBG, 0, 0, -603, 0, 250);
- schedule(250, 0, DelayInvHudClose);
- }
- function DelayInvHudClose(%this)
- {
- Canvas.popDialog(InvHud);
- if(Switch2.isVisible())
- Switch2.onClick();
- }
- function Switch1::onClick(%this)
- {
- slideElement(InvHudInnerContainer1, 22, 50, -556, 50, 250);
- slideElement(InvHudInnerContainer2, 603, 50, 22, 50, 250);
- Switch1.setVisible("0");
- Switch2.setVisible("1");
- wipeSkinHud();
- InvHudTitleText.setText("Change Your Skin");
- }
- function InvHudRespawn::onClick(%this)
- {
- commandToServer('RespawnPlayer');
- InvHud.close();
- }
- function Switch2::onClick(%this)
- {
- slideElement(InvHudInnerContainer2, 22, 50, 603, 50, 250);
- slideElement(InvHudInnerContainer1, -556, 50, 22, 50, 250);
- Switch1.setVisible("1");
- Switch2.setVisible("0");
- InvHudTitleText.setText("Create A Custom Class");
- }
- function InvHudLargeModelViewButton::onClick(%this)
- {
- InvHudLargeModelPreview.setVisible(true);
- slideElement(LoadoutBG, 0, 0, -603, 0, 250);
- }
- function InvHudLargeModelViewCloseButton::onClick(%this)
- {
- InvHudLargeModelPreview.setVisible(false);
- slideElement(LoadoutBG, -603, 0, 0, 0, 250);
- }
- function InvHud::OnWake(%this)
- {
- InvHudLoadoutList.clear();
- for(%i=0;%i < $InvHud::MaxLoadouts;%i++)
- {
- if($InvHud::MyLoadouts::Name[%i] !$= "")
- InvHudLoadoutList.addRow(%i, $InvHud::MyLoadouts::Name[%i]);
- }
- updateInvHudLoadout();
- }
- function InvHudClass::onSelect(%this)
- {
- if(!$InvHud::Init)
- {
- $Pref::InvHud::CurClass = %this.getText();
- commandToServer('RespawnPlayer');
- updateInvHudLoadout();
- }
- }
- function InvHudWeapon1::onSelect(%this)
- {
- if(!$InvHud::Init)
- {
- $Pref::InvHud::CurWep1 = %this.getText();
- updateInvHudLoadout();
- }
- }
- function InvHudWeapon2::onSelect(%this)
- {
- if(!$InvHud::Init)
- {
- $Pref::InvHud::CurWep2 = %this.getText();
- updateInvHudLoadout();
- }
- }
- function InvHudWeapon3::onSelect(%this)
- {
- if(!$InvHud::Init)
- {
- $Pref::InvHud::CurWep3 = %this.getText();
- updateInvHudLoadout();
- }
- }
- function InvHudOffhand::onSelect(%this)
- {
- if(!$InvHud::Init)
- {
- $Pref::InvHud::CurOH = %this.getText();
- updateInvHudLoadout();
- }
- }
- function InvHudCore::onSelect(%this)
- {
- if(!$InvHud::Init)
- {
- $Pref::InvHud::CurCore = %this.getText();
- updateInvHudLoadout();
- }
- }
- function InvHudSaveButton::onClick(%this)
- {
- if(InvHudLoadoutName.getValue() !$= "")
- {
- for(%i=0;%i < $InvHud::MaxLoadouts;%i++)
- {
- if($InvHud::MyLoadouts::Name[%i] $= "")
- {
- $InvHud::MyLoadouts::Name[%i] = InvHudLoadoutName.getValue();
- $InvHud::MyLoadouts::Class[%i] = $Pref::InvHud::CurClass;
- $InvHud::MyLoadouts::Wep1[%i] = $Pref::InvHud::CurWep1;
- $InvHud::MyLoadouts::Wep2[%i] = $Pref::InvHud::CurWep2;
- $InvHud::MyLoadouts::Wep3[%i] = $Pref::InvHud::CurWep3;
- $InvHud::MyLoadouts::OH[%i] = $Pref::InvHud::CurOH;
- $InvHud::MyLoadouts::Core[%i] = $Pref::InvHud::CurCore;
- $InvHud::MyLoadouts::Head[%i] = 0;
- $InvHud::MyLoadouts::Body[%i] = 0;
- export("$InvHud::MyLoadouts::*", "legions/preferences/MyLoadouts.cs", false);
- InvHudLoadoutList.addRow(%i, InvHudLoadoutName.getValue());
- %i = $InvHud::MaxLoadouts;
- InvHudLoadoutName.setValue("");
- }
- }
- }
- }
- function InvHudDelete::OnClick(%this)
- {
- %sel = InvHudLoadoutList.getSelectedId();
- if(%sel >= 0)
- {
- $InvHud::MyLoadouts::Name[%sel] = "";
- $InvHud::MyLoadouts::Class[%sel] = "";
- $InvHud::MyLoadouts::Wep1[%sel] = "";
- $InvHud::MyLoadouts::Wep2[%sel] = "";
- $InvHud::MyLoadouts::Wep3[%sel] = "";
- $InvHud::MyLoadouts::OH[%sel] = "";
- $InvHud::MyLoadouts::Core[%sel] = "";
- InvHudLoadoutList.removeRowById(%sel);
- export("$InvHud::MyLoadouts::*", "legions/preferences/MyLoadouts.cs", false);
- }
- }
- // Give them a default loadout the first time they start the game
- function InvHudLoadoutList::onAdd(%this)
- {
- if($Pref::Game::FirstStart != false || $Pref::Game::FirstStart $= "")
- {
- %hasLoadouts = false;
- for(%i = 0; %i < $InvHud::MaxLoadouts; %i++)
- {
- if($InvHud::MyLoadouts::Name[%i] !$= "")
- {
- %hasLoadouts = true;
- break;
- }
- }
- if(%hasLoadouts == false)
- {
- $InvHud::MyLoadouts::Name[0] = "Default";
- $InvHud::MyLoadouts::Class[0] = "Raider";
- $InvHud::MyLoadouts::Wep1[0] = "Chaingun";
- $InvHud::MyLoadouts::Wep2[0] = "Rocket Launcher";
- $InvHud::MyLoadouts::Wep3[0] = "Grenade Launcher";
- $InvHud::MyLoadouts::OH[0] = "Boost Grenade";
- $InvHud::MyLoadouts::Core[0] = "Overdrive";
- export("$InvHud::MyLoadouts::*", "legions/preferences/MyLoadouts.cs", false);
- InvHudLoadoutList.addRow(%i, InvHudLoadoutName.getValue());
- InvHudLoadoutName.setValue("");
- }
- $Pref::Game::FirstStart = false;
- }
- }
- function InvHudSelect::OnClick(%this)
- {
- %sel = InvHudLoadoutList.getSelectedId();
- if(%sel != -1)
- {
- $Sel = %sel;
- $Pref::InvHud::CurClass = $InvHud::MyLoadouts::Class[%sel];
- $Pref::InvHud::CurWep1 = $InvHud::MyLoadouts::Wep1[%sel];
- $Pref::InvHud::CurWep2 = $InvHud::MyLoadouts::Wep2[%sel];
- $Pref::InvHud::CurWep3 = $InvHud::MyLoadouts::Wep3[%sel];
- $Pref::InvHud::CurOH = $InvHud::MyLoadouts::OH[%sel];
- $Pref::InvHud::CurCore = $InvHud::MyLoadouts::Core[%sel];
- $Pref::SSel::Head = $InvHud::MyLoadouts::Head[%sel];
- $Pref::SSel::Body = $InvHud::MyLoadouts::Body[%sel];
- UploadSkinsRuntime();
- updateInvHudLoadout();
- commandToServer('RespawnPlayer');
- }
- // If the user clicked on the select command without
- // a selected loadout, give them defaults.
- // RR: Why? This fucks up the currently selected list...
- // So if you misclicked select instead of save button
- // you now have to select the loadout all over again...
- // Commenting it out.
- /*
- else
- {
- if($Pref::InvHud::CurClass $= "")
- $Pref::InvHud::CurClass = "Raider";
- if($Pref::InvHud::CurWep1 $= "")
- $Pref::InvHud::CurWep1 = "Chaingun";
- if($Pref::InvHud::CurWep2 $= "")
- $Pref::InvHud::CurWep2 = "Rocket Launcher";
- if($Pref::InvHud::CurWep3 $= "" && $Pref::InvHud::CurClass !$= "Outrider")
- $Pref::InvHud::CurWep3 = "Grenade Launcher";
- if($Pref::InvHud::CurOH $= "")
- $Pref::InvHud::CurOH = "Boost Grenade";
- if($Pref::InvHud::CurCore $= "")
- $Pref::InvHud::CurCore = "Overdrive";
- updateInvHudLoadout();
- }
- */
- }
- function KeyPadSelection(%sel)
- {
- if(%sel > -1 && %sel < 10)
- {
- $Pref::InvHud::CurClass = $InvHud::MyLoadouts::Class[%sel];
- $Pref::InvHud::CurWep1 = $InvHud::MyLoadouts::Wep1[%sel];
- $Pref::InvHud::CurWep2 = $InvHud::MyLoadouts::Wep2[%sel];
- $Pref::InvHud::CurWep3 = $InvHud::MyLoadouts::Wep3[%sel];
- $Pref::InvHud::CurOH = $InvHud::MyLoadouts::OH[%sel];
- $Pref::InvHud::CurCore = $InvHud::MyLoadouts::Core[%sel];
- $Pref::SSel::Head = $InvHud::MyLoadouts::Head[%sel];
- $Pref::SSel::Body = $InvHud::MyLoadouts::Body[%sel];
- $Sel = %sel;
- UploadSkinsRuntime();
- updateInvHudLoadout();
- commandToServer('RespawnPlayer');
- }
- // If the user clicked on the select command without
- // a selected loadout, give them defaults.
- // RR: Again... Why?
- /*
- else
- {
- if($Pref::InvHud::CurClass $= "")
- $Pref::InvHud::CurClass = "Raider";
- if($Pref::InvHud::CurWep1 $= "")
- $Pref::InvHud::CurWep1 = "Chaingun";
- if($Pref::InvHud::CurWep2 $= "")
- $Pref::InvHud::CurWep2 = "Rocket Launcher";
- if($Pref::InvHud::CurWep3 $= "" && $Pref::InvHud::CurClass !$= "Outrider")
- $Pref::InvHud::CurWep3 = "Grenade Launcher";
- if($Pref::InvHud::CurOH $= "")
- $Pref::InvHud::CurOH = "Boost Grenade";
- if($Pref::InvHud::CurCore $= "")
- $Pref::InvHud::CurCore = "Overdrive";
- updateInvHudLoadout();
- }
- */
- }
- function updateInvHudLoadout()
- {
- $InvHud::Init = true;
- InvHudClass.clear();
- %count = InvHudListClass.getCount();
- for(%i=0;%i<%count;%i++)
- {
- InvHudClass.add(InvHudListClass.getObject(%i).name, %i);
- }
- InvHudClass.setSelected(InvHudClass.findText($Pref::InvHud::CurClass));
- InvHudClass.toolTip = $itemDescription[$Pref::InvHud::CurClass];
- if($InvHud::ListNTID[InvHudClass.getText()].maxInvCount < 3)
- {
- InvHudWeapon3.visible = false;
- if($InvHud::ListNTID[InvHudClass.getText()].maxInvCount < 2)
- {
- InvHudWeapon2.visible = false;
- $Pref::InvHud::CurWep2 = "";
- $Pref::InvHud::CurWep3 = "";
- }
- else
- {
- InvHudWeapon2.visible = true;
- $Pref::InvHud::CurWep3 = "";
- }
- }
- else
- {
- InvHudWeapon2.visible = true;
- InvHudWeapon3.visible = true;
- }
- InvHudWeapon1.clear();
- %count = InvHudListWeapon.getCount();
- for(%i=0;%i<%count;%i++)
- {
- %obj = InvHudListWeapon.getObject(%i).name;
- if ((%obj !$= $Pref::InvHud::CurWep2) && (%obj !$= $Pref::InvHud::CurWep3))
- InvHudWeapon1.add(InvHudListWeapon.getObject(%i).name, %i);
- }
- InvHudWeapon1.setSelected(InvHudWeapon1.findText($Pref::InvHud::CurWep1));
- InvHudWeapon1.toolTip = $itemDescription[$Pref::InvHud::CurWep1];
- InvHudWeapon2.clear();
- for(%i=0;%i<%count;%i++)
- {
- %obj = InvHudListWeapon.getObject(%i).name;
- if ((%obj !$= $Pref::InvHud::CurWep1) && (%obj !$= $Pref::InvHud::CurWep3))
- InvHudWeapon2.add(%obj, %i);
- }
- InvHudWeapon2.setSelected(InvHudWeapon2.findText($Pref::InvHud::CurWep2));
- InvHudWeapon2.toolTip = $itemDescription[$Pref::InvHud::CurWep2];
- InvHudWeapon3.clear();
- for(%i=0;%i<%count;%i++)
- {
- %obj = InvHudListWeapon.getObject(%i).name;
- if ((%obj !$= $Pref::InvHud::CurWep1) && (%obj !$= $Pref::InvHud::CurWep2))
- InvHudWeapon3.add(InvHudListWeapon.getObject(%i).name, %i);
- }
- InvHudWeapon3.setSelected(InvHudWeapon3.findText($Pref::InvHud::CurWep3));
- InvHudWeapon3.toolTip = $itemDescription[$Pref::InvHud::CurWep3];
- InvHudOffhand.clear();
- %count = InvHudListOffhand.getCount();
- for(%i=0;%i<%count;%i++)
- {
- InvHudOffhand.add(InvHudListOffhand.getObject(%i).name, %i);
- }
- InvHudOffhand.setSelected(InvHudOffhand.findText($Pref::InvHud::CurOH));
- InvHudOffhand.toolTip = $itemDescription[$Pref::InvHud::CurOH];
- InvHudCore.clear();
- %count = InvHudListCore.getCount();
- for(%i=0;%i<%count;%i++)
- {
- InvHudCore.add(InvHudListCore.getObject(%i).name, %i);
- }
- InvHudCore.setSelected(InvHudCore.findText($Pref::InvHud::CurCore));
- InvHudCore.toolTip = $itemDescription[$Pref::InvHud::CurCore];
- $InvHud::Init = false;
- commandToServer('SetupLoadout',
- $InvHud::ListNTID[$Pref::InvHud::CurClass].dataBlock,
- $InvHud::ListNTID[$Pref::InvHud::CurWep1].dataBlock TAB
- $InvHud::ListNTID[$Pref::InvHud::CurWep2].dataBlock TAB
- $InvHud::ListNTID[$Pref::InvHud::CurWep3].dataBlock,
- $InvHud::ListNTID[$Pref::InvHud::CurOH].dataBlock,
- $InvHud::ListNTID[$Pref::InvHud::CurCore].dataBlock );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement