Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   New F3 options tab (https://forums.graalonline.com/forums/showthread.php?t=134267533)

xXziroXx 12-09-2012 07:14 AM

New F3 options tab
 
I figured it was a better and more logical idea to add local serveroptions at the same place that all other options were located, so I wrote up some code that allows you to do that.


PHP Code:

//#CLIENTSIDE
const SERVERNAME "Maloria";  // Change this to your likings.

function onCreated()
  if (
OptDialogWindow2D.visible)
    
setInitialData();

function 
OptDialogWindow2D.onShow()
{
  if (!
isObject(OptionTabs))
    
setInitialData();
  
  
updateSelectedTab();
  
  if (
OptDialogTab.rows[1].text != SERVERNAME) {
    
this.originalSize = { 444404 };  // Default dimensions of OptDialogWindow2D
    
    
OptDialogWindow2D.resize(OptDialogWindow2D.xOptDialogWindow2D.ythis.originalSize[0] + 47this.originalSize[1]);
    
    
OptDialogTab.insertRow(14SERVERNAME);
  }
  
  new 
GuiControl("OptServerPane2D") {
    
this.profile GuiOptPaneProfile;
    
    
this.x      OptGeneralPane2D.x;
    
this.y      OptGeneralPane2D.y;
    
this.width  OptGeneralPane2D.width;
    
this.height OptGeneralPane2D.height;
    
    
this.visible false;
    
    
OptDialogWindow2D.addControl(this);
    
    
// Add subsequent GUI controls here
  
}
  
  
OptDialogTab.setSelectedRow(0);
}

function 
OptDialogTab.onSelect(temp.idtemp.texttemp.row)
{
  if (
temp.text == SERVERNAME) {
    
temp.lastSelectedTabName getSelectedTabText();
    
OptionTabs.(@temp.lastSelectedTabName).hide();
    
    
OptServerPane2D.show();
  }
  else if (
OptServerPane2D.visible)
    
OptServerPane2D.hide();
  
  
updateSelectedTab();
}



function 
setInitialData()
{
  
this.tabs          = new TStaticVar("OptionTabs");
  
  
OptionTabs.General OptGeneralPane2D;
  
OptionTabs.Sound   OptAudioPane2D;
  
OptionTabs.Keys    OptControlsPane2D;
  
OptionTabs.Capture OptCapturePane2D;
}

function 
updateSelectedTab()
  
this.selectedTab OptDialogTab.getselectedrow();
function 
getSelectedTabID()
  return 
this.selectedTab;
function 
getSelectedTabText()
  return 
OptDialogTab.rows[getSelectedTabID()].text

Each time that the F3 menu is opened, it clears tabs. This is a great thing, because it means your custom tabs won't remain upon changing servers. The only change that will remain until your game client is restarted, is that the windows width is slightly increased when the new tab is added. This could likely be easily fixed if the script on Login would be updated by Stefan/Skyld/Tig to reset the windows dimensions each time it's opened.

Enjoy :)


All times are GMT +2. The time now is 04:48 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.