View Single Post
  #2  
Old 08-19-2010, 01:19 AM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
Because Graal Forums don't like me, I cut out the main login message (text too long)

PHP Code:
function onActionServerSide( afi, var ) {
  switch( 
afi ) {
    case 
"receiveNews": {
      
temp.news.loadLines( "control/s_news.txt" );
      
triggerClient( "gui", name, "getNews", temp.news );
      break;
    }
    case 
"receiveProgress": {
      
temp.progress.loadLines( "control/s_progress.txt" );
      
triggerClient( "gui", name, "getProgress", temp.progress );
      break;
    }
    case 
"receiveStaff": {
      
temp.staff.loadLines( "control/s_staff.txt" );
      
triggerClient( "gui", name, "getStaff", temp.staff );
      break;
    }
    case 
"receiveHirings": {
      
temp.hirings.loadLines( "control/s_hirings.txt" );
      
triggerClient( "gui", name, "getHirings", temp.hirings );
      break;
    }
    case 
"editNews": {
      
temp.news = { var };
      
temp.news.saveLines( "control/s_news.txt", 0 );
      break;
    }
    case 
"editProgress": {
      
temp.progress = { var };
      
temp.progress.saveLines( "control/s_progress.txt", 0 );
      break;
    }
    case 
"editStaff": {
      
temp.staff = { var };
      
temp.staff.saveLines( "control/s_staff.txt", 0 );
      break;
    }
    case 
"editHirings": {
      
temp.hirings = { var };
      
temp.hirings.saveLines( "control/s_hirings.txt", 0 );
      break;
    }
  }
}

//#CLIENTSIDE

function onActionClientSide( afi, news, progress, staff, hirings ) {
  switch( 
afi ) {
    case 
"getNews": {
      for ( 
temp.a : news ) {
        
temp.ne @= temp.a @ "\n";
      }
      
onEditNews( temp.ne );
      break;
    }
    case 
"getProgress": {
      
// Nothing is received here (progress = 0, temp.pro = 0, temp.a = 0)
      
for ( temp.a : progress ) {
        
temp.pro @= temp.a @ "\n";
      }
      
onEditProgress( temp.pro );
      break;
    }
    case 
"getStaff": {
      
// Same thing as progress, nothing receives here.
      
for ( temp.a : staff ) {
        
temp.s @= temp.a @ "\n";
      }
      
onEditStaff( temp.s );
      break;
    }
    case 
"getHirings": {
      
// Ditto
      
for ( temp.a : hirings ) {
        
temp.h @= temp.a @ "\n";
      }
      
onEditHirings( temp.h );
      break;
    }
  }
}

function 
onPlayerChats() {
  if ( 
player.chat == ":edit news" ) {
    
player.chat = "";
    
triggerServer( "gui", name, "receiveNews" );
  }
  if ( 
player.chat == ":edit progress" ) {
    
player.chat = "";
    
triggerServer( "gui", name, "receiveProgress" );
  }
  if ( 
player.chat == ":edit staff" ) {
    
player.chat = "";
    
triggerServer( "gui", name, "receiveStaff" );
  }
  if ( 
player.chat == ":edit hirings" ) {
    
player.chat = "";
    
triggerServer( "gui", name, "receiveHirings" );
  }
}

function 
onEditNews( news ) {
  new 
GuiWindowCtrl( "News_Window" ) {
    
profile = GuiWindowProfile;
    
x = screenwidth / 2 - ( width / 2 );
    
y = screenheight / 2 - ( height / 2 );
    
clientRelative = true;
    
clientExtent = "428,338";
    
canMaximize = false;
    
canMove = true;
    
canResize = false;
    
canClose = true;
    
closeQuery = false;
    
destroyOnHide = true;
    
text = "Editing Tab: News";

    new 
GuiScrollCtrl( "News_News_Scroll" ) {
      
profile = GuiScrollProfile;
      
height = 292;
      
hScrollBar = "dynamic";
      
vScrollBar = "alwaysOff";
      
width = 428;

      new 
GuiMLTextEditCtrl( "News_News" ) {
        
profile = GuiMLTextEditProfile;
        
height = 16;
        
horizSizing = "width";
        
text = news;
        
width = 403;
      }
    }
    
    new 
GuiButtonCtrl( "News_Save" ) {
      
profile = GuiButtonProfile;
      
height = 43;
      
text = "Save Tab: News";
      
width = 428;
      
y = 295;
    }
  }
}

function 
News_Save.onAction() {
  
triggerServer( "gui", name, "editNews", News_News.text );
  
News_Window.destroy();
}

function 
onEditProgress( progress ) {
  new 
GuiWindowCtrl( "Progress_Window" ) {
    
profile = GuiWindowProfile;
    
x = screenwidth / 2 - ( width / 2 );
    
y = screenheight / 2 - ( height / 2 );
    
clientRelative = true;
    
clientExtent = "428,338";
    
canMaximize = false;
    
canMove = true;
    
canResize = false;
    
canClose = true;
    
closeQuery = false;
    
destroyOnHide = true;
    
text = "Editing Tab: Progress";

    new 
GuiScrollCtrl( "Progress_Scroll" ) {
      
profile = GuiScrollProfile;
      
height = 292;
      
hScrollBar = "dynamic";
      
vScrollBar = "alwaysOff";
      
width = 428;

      new 
GuiMLTextEditCtrl( "Progress_Progress" ) {
        
profile = GuiMLTextEditProfile;
        
height = 16;
        
horizSizing = "width";
        
text = progress;
        
width = 403;
      }
    }
    
    new 
GuiButtonCtrl( "Progress_Save" ) {
      
profile = GuiButtonProfile;
      
height = 43;
      
text = "Save Tab: Progress";
      
width = 428;
      
y = 295;
    }
  }
}

function 
Progress_Save.onAction() {
  
triggerServer( "gui", name, "editProgress", Progress_Progress.text );
  
Progress_Window.destroy();
}

function 
onEditStaff( staff ) {
  new 
GuiWindowCtrl( "Staff_Window" ) {
    
profile = GuiWindowProfile;
    
x = screenwidth / 2 - ( width / 2 );
    
y = screenheight / 2 - ( height / 2 );
    
clientRelative = true;
    
clientExtent = "428,338";
    
canMaximize = false;
    
canMove = true;
    
canResize = false;
    
canClose = true;
    
closeQuery = false;
    
destroyOnHide = true;
    
text = "Editing Tab: Staff";

    new 
GuiScrollCtrl( "Staff_Staff_Scroll" ) {
      
profile = GuiScrollProfile;
      
height = 292;
      
hScrollBar = "dynamic";
      
vScrollBar = "alwaysOff";
      
width = 428;

      new 
GuiMLTextEditCtrl( "Staff_Staff" ) {
        
profile = GuiMLTextEditProfile;
        
height = 16;
        
horizSizing = "width";
        
text = staff;
        
width = 403;
      }
    }
    
    new 
GuiButtonCtrl( "Staff_Save" ) {
      
profile = GuiButtonProfile;
      
height = 43;
      
text = "Save Tab: Staff";
      
width = 428;
      
y = 295;
    }
  }
}

function 
Staff_Save.onAction() {
  
triggerServer( "gui", name, "editStaff", Staff_Staff.text );
  
Staff_Window.destroy();
}

function 
onEditHirings( hirings ) {
  new 
GuiWindowCtrl( "Hirings_Window" ) {
    
profile = GuiWindowProfile;
    
x = screenwidth / 2 - ( width / 2 );
    
y = screenheight / 2 - ( height / 2 );
    
clientRelative = true;
    
clientExtent = "428,338";
    
canMaximize = false;
    
canMove = true;
    
canResize = false;
    
canClose = true;
    
closeQuery = false;
    
destroyOnHide = true;
    
text = "Editing Tab: Hirings";

    new 
GuiScrollCtrl( "Hirings_Hirings_Scroll" ) {
      
profile = GuiScrollProfile;
      
height = 292;
      
hScrollBar = "dynamic";
      
vScrollBar = "alwaysOff";
      
width = 428;

      new 
GuiMLTextEditCtrl( "Hirings_Hirings" ) {
        
profile = GuiMLTextEditProfile;
        
height = 16;
        
horizSizing = "width";
        
text = hirings;
        
width = 403;
      }
    }
    
    new 
GuiButtonCtrl( "Hirings_Save" ) {
      
profile = GuiButtonProfile;
      
height = 43;
      
text = "Save Tab: Hirings";
      
width = 428;
      
y = 295;
    }
  }
}

function 
Hirings_Save.onAction() {
  
triggerServer( "gui", name, "editHirings", Hirings_Hirings.text );
  
Hirings_Window.destroy();
} 
Reply With Quote