Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   News-Window (https://forums.graalonline.com/forums/showthread.php?t=84684)

Schetti 03-14-2009 05:56 PM

News-Window
 
I hope you like this news window.
You can list News/Updates, Hiring infos and currently staffs.
Thats my first post, so dont bee too hard.

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
ExampleWindow = new GuiWindowCtrl("ExampleWindow");
  
  
with (ExampleWindow)
  {
    
profile     "GuiBlueWindowProfile";
    
position    "562 225";
    
extent      "545 555";
    
canMove     true;
    
canResize   false;
    
canMaximize false;
    
canClose    true;
    
tile        true;
    
text        "News";
    
    new 
GuiControl(NewsTab)
    {
      
visible    false;
      
profile    "GuiBlueControlProfile";
      
position   "7.5 52";
      
extent     "531 495";
      
    new 
GuiScrollCtrl("MyGUI_MultiLine1_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 800;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 800;
      
1;

      new 
GuiMLTextCtrl("MyGUI_MultiLine1") {
        
profile GuiBlueMLTextProfile;
        
height 16;
        
horizsizing "width";
        
text " News here";                                        

        
width 518;
       }
      };
    };
    
    new 
GuiControl(HiringsTab)
    {
      
visible    false;
      
profile    "GuiBlueControlProfile";
      
position   "7.5 52";
      
extent     "531 495";
      
    new 
GuiScrollCtrl("MyGUI_MultiLine2_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 800;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 800;
      
1;

      new 
GuiMLTextCtrl("MyGUI_MultiLine2") {
        
profile GuiBlueMLTextProfile;
        
height 16;
        
horizsizing "width";
        
text "Hiring datas here";                                        

        
width 518;
      }
    };
   };
    
    new 
GuiControl(StaffsTab)
    {
      
visible    false;
      
profile    "GuiBlueControlProfile";
      
position   "7.5 52";
      
extent     "531 495";
      
    new 
GuiScrollCtrl("MyGUI_MultiLine3_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 800;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 800;
      
1;

      new 
GuiMLTextCtrl("MyGUI_MultiLine3") {
        
profile GuiBlueMLTextProfile;
        
height 16;
        
horizsizing "width";
        
text "Staff list here";                                        

        
width 518;
       }
      };
    };
    
    new 
GuiTabCtrl(ExampleTabs)
    {
      
profile   "GuiBlueTabProfile";
      
position  "10 28";
      
extent    "300 24";
      
      
clearRows();
      
with (addRow(0"News"))
      {
        
this.pane NewsTab;
      }
      
with (addRow(1"Hirings"))
      {
        
this.pane HiringsTab;
      }
      
with (addRow(2"Staffs"))
      {
        
this.pane StaffsTab;
      }
      
      
thiso.catchevent(name"onSelect""onTabSelect");
    };
  };
  
ExampleTabs.setSelectedById(0);
  
GraalControl.addControl(ExampleWindow);
}

function 
onTabSelect(tabs)
{
  for (
temp.tabtemp.tabs.rows)
  {
    if (
temp.tab.pane == null)
    {
      continue;
    }
    
    if (
temp.tab == temp.tabs.selected)
    {
      
temp.tab.pane.show();
    }
    else
    {
      
temp.tab.pane.hide();
    }
  }



Angel_Light 03-14-2009 06:34 PM

Good Job, looks quite professional. =]

styling tip : With multiple vars that are being set to the same thing you can just use '='
ie
PHP Code:

....  
  
tile     
  
canMove  =
  
canClose true;

  
canResize   =
  
canMaximize false;
.... 

also, you can save lines by using

position = { x, y};
extent = { width, height};

in this format you can do operations which you can't do in the "x y" format.

cbk1994 03-14-2009 08:16 PM

Looks good. Can you post a screenshot? I made something similar here.

Schetti 03-14-2009 08:32 PM

1 Attachment(s)
>_<

if I see that one mines bad.
:cry:

cyan3 03-14-2009 08:52 PM

Nice work, it looks great ^^

cbk1994 03-14-2009 09:49 PM

I like yours. Only thing is it might be a bit too large.

Schetti 03-14-2009 10:00 PM

Well
I have to learn how to use scrolls,
so I made it big eneugh for begin.

xXziroXx 03-14-2009 11:15 PM

Quote:

Originally Posted by Angel_Light (Post 1474443)
styling tip : With multiple vars that are being set to the same thing you can just use '='

That's the worst suggestion I've seen posted in a long time. For one, it would require you to edit the "max length" of all the variable as soon as you add a new variable that has a longer name then the previously longest one.

MiniOne 03-14-2009 11:41 PM

I think stefan stole your idea xD

LoneAngelIbesu 03-15-2009 01:23 AM

I would suggest a GUI that can post the news to a file, and then load the text from that file in to the various tabbed panes.

I find that sticking to a single project and making it perfect is the best way to learn how to script.

Codein 03-15-2009 01:46 AM

Quote:

Originally Posted by xXziroXx (Post 1474562)
That's the worst suggestion I've seen posted in a long time. For one, it would require you to edit the "max length" of all the variable as soon as you add a new variable that has a longer name then the previously longest one.

I think he was refering to doing something like this:
temp.foo = temp.bar = 2;
However, I do agree with you.

cyan3 03-15-2009 02:29 AM

Quote:

Originally Posted by Schetti (Post 1474530)
Well
I have to learn how to use scrolls,
so I made it big eneugh for begin.

Correct me if I'm wrong but won't this make the gui scroll?

PHP Code:

new GuiScrollCtrl("MyGUI_MultiLine1_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 800;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 800;
      
1;

      new 
GuiMLTextCtrl("MyGUI_MultiLine1") {
        
profile GuiBlueMLTextProfile;
        
height 16;
        
horizsizing "width";
        
text " News here";                                        

        
width 518;
       }
      }; 


Angel_Light 03-15-2009 03:19 AM

Quote:

Originally Posted by xXziroXx (Post 1474562)
That's the worst suggestion I've seen posted in a long time. For one, it would require you to edit the "max length" of all the variable as soon as you add a new variable that has a longer name then the previously longest one.

I don't get the problem, it works great for me and I have never had a problem with it.... x_x

Schetti 03-15-2009 07:20 AM

Quote:

Originally Posted by cyan3 (Post 1474627)
Correct me if I'm wrong but won't this make the gui scroll?

PHP Code:

new GuiScrollCtrl("MyGUI_MultiLine1_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 800;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 800;
      
1;

      new 
GuiMLTextCtrl("MyGUI_MultiLine1") {
        
profile GuiBlueMLTextProfile;
        
height 16;
        
horizsizing "width";
        
text " News here";                                        

        
width 518;
       }
      }; 


umm...
I dont think so.
I made a LOOOOONG text, and it just didnt show up anymore.

how to say ...

the text goes out of the news window and wont be showen.

Mark Sir Link 03-15-2009 07:31 AM

it'd be a good idea to name the GUI objects something useful rather than "ExampleWindow" and MyGUI_ScrollLine2 etc

xXziroXx 03-15-2009 11:50 AM

Quote:

Originally Posted by Angel_Light (Post 1474639)
I don't get the problem, it works great for me and I have never had a problem with it.... x_x

Then you're just overcomplicating something that should be simple. :D

Angel_Light 03-15-2009 12:14 PM

Quote:

Originally Posted by xXziroXx (Post 1474700)
Then you're just overcomplicating something that should be simple. :D

lol, xD I think I understand what you mean, but it seems repetitive have several vars being set to the same value over and over, while you could just set all the values once.

Quote:

Originally Posted by Schetti (Post 1474682)
umm...
I dont think so.
I made a LOOOOONG text, and it just didnt show up anymore.

how to say ...

the text goes out of the news window and wont be showen.

that means your MLText width is bigger than window width, try reducing, I usually take the gui width and - 20 for inner texts widths (compensation for the vscrollbar)

salesman 03-15-2009 04:30 PM

I don't think you guys are referring to the same thing.

(?)Angel_Light is referring to this as good practice:
PHP Code:

temp.foo temp.bar temp.yay 42

(?)and Ziro is referring to this as crappy styling:
PHP Code:

temp.foo     3;
temp.bar     7;
temp.yai     10;
temp.crapthisoneislongerthantherest 20;
temp.nowihavetoreadjustallofthepreviousspacing "frown"

Correct me if I'm wrong.

Angel_Light 03-15-2009 06:22 PM

Quote:

Originally Posted by salesman (Post 1474748)
I don't think you guys are referring to the same thing.

(?)Angel_Light is referring to this as good practice:
PHP Code:

temp.foo temp.bar temp.yay 42

(?)and Ziro is referring to this as crappy styling:
PHP Code:

temp.foo     3;
temp.bar     7;
temp.yai     10;
temp.crapthisoneislongerthantherest 20;
temp.nowihavetoreadjustallofthepreviousspacing "frown"

Correct me if I'm wrong.

That's what I'm talking about...

Codein 03-15-2009 06:48 PM

Either way, I prefer doing it like this:

PHP Code:

temp.var1 true;
temp.var2 true;
temp.var3 true

so then I can easily do, say, temp.var2 = false, without having to mess around.

Angel_Light 03-15-2009 08:10 PM

Quote:

Originally Posted by Codein (Post 1474784)
Either way, I prefer doing it like this:

PHP Code:

temp.var1 true;
temp.var2 true;
temp.var3 true

so then I can easily do, say, temp.var2 = false, without having to mess around.

styling choice really. although they both produce the same results. =P

Codein 03-16-2009 11:36 PM

Quote:

Originally Posted by Angel_Light (Post 1474811)
styling choice really. although they both produce the same results. =P

I'd say it was a choice between "Waste time once or waste time multiple times later", but that's just my honest opinion. Only really good, in my opinion (opinion being key here), for when you're assigning multiple variables (see example), but, even still, I don't like doing that.

PHP Code:

temp.var = 3;
temp.var2 temp.var3 temp.var1


Deas_Voice 03-17-2009 08:21 PM

okey, we get it, stop argue about it! x_x

Schetti 03-26-2009 03:14 PM

With Scroll, FINALLY!
 
1 Attachment(s)
Now with scroll, smaller and also position = {}; extent = {}; stuff and better names(NewsTab etc.).
Also, if you want to use it(for those who didnt know)
Save it for example under -System/News
and after that, open the script for Control-NPC and add this
PHP Code:

function onActionPlayerOnline(){
  
addweapon("-System/News");


And this is the Final News-Window
PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
NewsWindow = new GuiWindowCtrl("NewsWindow");
  
  
with (NewsWindow)
  {
    
profile     "GuiBlueWindowProfile"
    
position    "640 390";
    
extent      "380 380";
    
canMove     true
    
canResize   false
    
canMaximize false
    
canClose    true
    
tile        true
    
text        "News"
    
    new 
GuiControl(NewsTab)
    {
      
visible    false;
      
profile    "GuiBlueControlProfile";
      
position   "10 52";
      
extent     "360 310";
      
    new 
GuiScrollCtrl("NewsScroll") {
      
profile GuiBlueScrollProfile;
      
position = { 510};
      
extent = { 350300};
      
hscrollbar "alwaysOff";
      
vscrollbar "alwaysOn";


    new 
GuiMLTextCtrl("NewsList") { 

         
profile GuiBlueMLTextProfile;
         
extent = { 51832};   
        
horizsizing "width";
text "
Insert News here ^^
        "
;                                            

      };
    }
    };
    
    new 
GuiControl(HiringsTab)
    {
      
visible    false;
      
profile    "GuiBlueControlProfile";
      
position   "10 52";
      
extent     "360 310";
      
    new 
GuiScrollCtrl("HiringsScroll") {
      
profile GuiBlueScrollProfile;
      
position = { 510};
      
extent = { 350300};
      
hscrollbar "alwaysOff";
      
vscrollbar "alwaysOn";


    new 
GuiMLTextCtrl("HiringsList") {
        
profile GuiBlueMLTextProfile
        
horizsizing "width";
extent = { 34732};
text "
Insert Hirings stuff here ^^

        "
;    
       
      };
    }
    };
    
    new 
GuiControl(StaffTab)
    {
      
visible    false;
      
profile    "GuiBlueControlProfile";
      
position   "10 52";
      
extent     "360 310";
      
    new 
GuiScrollCtrl("StaffScroll") {
      
profile GuiBlueScrollProfile;
      
position = { 510};
      
extent = { 350300};
      
hscrollbar "alwaysOff";
      
vscrollbar "alwaysOn";


    new 
GuiMLTextCtrl("StaffList") {
        
profile GuiBlueMLTextProfile
        
horizsizing "width";
        
position = { xy};
        
extent = { 34732};
text "
Insert staff list here ^^
"
;    
       
      };
    }
    };
    
    new 
GuiTabCtrl(ExampleTabs)
    {
      
profile   "GuiBlueTabProfile";
      
position  "10 28";
      
extent    "300 24";
      
      
clearRows();
      
with (addRow(0"News"))
      {
        
this.pane NewsTab;
      }
      
with (addRow(1"Hirings"))
      {
        
this.pane HiringsTab;
      }
      
with (addRow(2"Staff"))
      {
        
this.pane StaffTab;
      }
      
      
thiso.catchevent(name"onSelect""onTabSelect");
    };
  };
  
ExampleTabs.setSelectedById(0);
  
GraalControl.addControl(NewsWindow);
}

function 
onTabSelect(tabs)
{
  for (
temp.tabtemp.tabs.rows)
  {
    if (
temp.tab.pane == null)
    {
      continue;
    }
    
    if (
temp.tab == temp.tabs.selected)
    {
      
temp.tab.pane.show();
    }
    else
    {
      
temp.tab.pane.hide();
    }
  }



xfazex 03-31-2009 03:39 AM

Errors from this script:

PHP Code:

ScriptCouldn't create object: type GuiWindowCtrl is not existing at line 4 in script of -System/News
Script: Couldn'
t create objecttype GuiControl is not existing at line 18 in script of -System/News
Script
Couldn't create object: type GuiScrollCtrl is not existing at line 25 in script of -System/News
Script: Couldn'
t create objecttype GuiMLTextCtrl is not existing at line 33 in script of -System/News
Script
: Function addcontrol not found at line 33 in script of -System/News
Script
: Function addcontrol not found at line 25 in script of -System/News
Script
: Function addcontrol not found at line 18 in script of -System/News
Script
Couldn't create object: type GuiControl is not existing at line 44 in script of -System/News
Script: Couldn'
t create objecttype GuiScrollCtrl is not existing at line 51 in script of -System/News
Script
Couldn't create object: type GuiMLTextCtrl is not existing at line 59 in script of -System/News
Script: Function addcontrol not found at line 59 in script of -System/News
Script: Function addcontrol not found at line 51 in script of -System/News
Script: Function addcontrol not found at line 44 in script of -System/News
Script: Couldn'
t create objecttype GuiControl is not existing at line 70 in script of -System/News
Script
Couldn't create object: type GuiScrollCtrl is not existing at line 77 in script of -System/News
Script: Couldn'
t create objecttype GuiMLTextCtrl is not existing at line 85 in script of -System/News
Script
: Function addcontrol not found at line 85 in script of -System/News
Script
: Function addcontrol not found at line 77 in script of -System/News
Script
: Function addcontrol not found at line 70 in script of -System/News
Script
Couldn't create object: type GuiTabCtrl is not existing at line 96 in script of -System/News 


Schetti 04-09-2009 06:45 PM

lawl, maybe I shouldnt "edit" the script and just post the one I use:


If this doesnt work, I should stop scripting
PHP Code:

//Made by Schetti
/* useful Codes:
<b>text</b>
<u>text</u>
<i>text</i>
<center>text</center>
*/

//#CLIENTSIDE
function onCreated()
{
  
NewsWindow = new GuiWindowCtrl("NewsWindow");
  
  
with (NewsWindow)
  {
    
profile     "GuiBlueWindowProfile"
    
position    "640 390";
    
extent      "380 380";
    
canMove     true
    
canResize   false
    
canMaximize false
    
canClose    true
    
tile        true
    
text        "Supernova-News"
    
    new 
GuiControl(NewsTab)
    {
      
visible    false;
      
profile    "GuiBlueControlProfile";
      
position   "10 52";
      
extent     "360 310";
      
    new 
GuiScrollCtrl("NewsScroll") {
      
profile GuiBlueScrollProfile;
      
position = { 510};
      
extent = { 350300};
      
hscrollbar "alwaysOff";
      
vscrollbar "alwaysOn";


    new 
GuiMLTextCtrl("NewsList") { 

         
profile GuiBlueMLTextProfile;
         
extent = { 51832};   
        
horizsizing "width";
text "
<u><b>Schetti:</b></u>
I am working on our mine system,
but it needs GFX!

<u><b>Lucas:</b></u>
Finally we got tailor (Schetti
made it,much thanks to he for that) 
to open it say /tailor.

<u><b>Schetti:</b></u>
The newswindow is fixed now.
We are working on some quests now.

<u><b>Schetti:</b></u>
I am is working on a new Event. 
I hope it works
"
;                                            

      };
    }
    };
    
    new 
GuiControl(HiringsTab)
    {
      
visible    false;
      
profile    "GuiBlueControlProfile";
      
position   "10 52";
      
extent     "360 310";
      
    new 
GuiScrollCtrl("HiringsScroll") {
      
profile GuiBlueScrollProfile;
      
position = { 510};
      
extent = { 350300};
      
hscrollbar "alwaysOff";
      
vscrollbar "alwaysOn";


    new 
GuiMLTextCtrl("HiringsList") {
        
profile GuiBlueMLTextProfile
        
horizsizing "width";
extent = { 34732};
text "
We are currently under construction and we hire every kind of staff 
exept FAQ/GP and ET.

<b>WE HARDLY NEED SCRIPTERS(NAT)!
Just send us 2-3 of your best scripts.</b>

If you're interested write an E-Mail to:
                                         
[email protected]
or  [email protected]
                                                                                                       
with some of your levels, ganis or what ever you make at your job                 
and some personal stuff like: 
your experience on other servers, 
why you want to be staff here, 
and why do you think we should take you 
instead of another applicant.

LATs can contact Schetti or Lucas3 if they are online.
We might give you OnlineEditor so you can show us what you can.

You also can say 
/latapply  or
/gfxapply



<b>IMPORTAND!</b>
Please dont write an apply, if you aren't Gold.
        "
;    
       
      };
    }
    };
    
    new 
GuiControl(StaffTab)
    {
      
visible    false;
      
profile    "GuiBlueControlProfile";
      
position   "10 52";
      
extent     "360 310";
      
    new 
GuiScrollCtrl("StaffScroll") {
      
profile GuiBlueScrollProfile;
      
position = { 510};
      
extent = { 350300};
      
hscrollbar "alwaysOff";
      
vscrollbar "alwaysOn";


    new 
GuiMLTextCtrl("StaffList") {
        
profile GuiBlueMLTextProfile
        
horizsizing "width";
        
position = { xy};
        
extent = { 34732};
text "
*Owner*
Lucas3

*CO-Owner*
<b>needed</b>  

*Manager*
<b>needed</b> 
                                                                                                                                                                
*Developer*
PowerProNL
tstre

*GFX*
<b>needed</b>

*LAT*
Schetti
Valtor
sonnfel"
;    
       
      };
    }
    };
    
    new 
GuiTabCtrl(ExampleTabs)
    {
      
profile   "GuiBlueTabProfile";
      
position  "10 28";
      
extent    "300 24";
      
      
clearRows();
      
with (addRow(0"News"))
      {
        
this.pane NewsTab;
      }
      
with (addRow(1"Hirings"))
      {
        
this.pane HiringsTab;
      }
      
with (addRow(2"Staff"))
      {
        
this.pane StaffTab;
      }
      
      
thiso.catchevent(name"onSelect""onTabSelect");
    };
  };
  
ExampleTabs.setSelectedById(0);
  
GraalControl.addControl(NewsWindow);
}

function 
onTabSelect(tabs)
{
  for (
temp.tabtemp.tabs.rows)
  {
    if (
temp.tab.pane == null)
    {
      continue;
    }
    
    if (
temp.tab == temp.tabs.selected)
    {
      
temp.tab.pane.show();
    }
    else
    {
      
temp.tab.pane.hide();
    }
  }



devilsknite1 04-09-2009 08:55 PM

I'd suggest using
PHP Code:

NL 

on your text = ""; line. NL means Next Line.

It would look something like this:
PHP Code:

text "hi" NL "<b><u><font color=000000>black font that's bold and underlined!</font></u></b>" NL "weee"

Not sure if I'm right, but just doing enter's won't create new lines. If it does, then cool, you can keep doing it that way and ignore what I said :D
I guess it's personal preference, though. It just might free up some space in that script.

[email protected] 04-09-2009 09:06 PM

Or you can use
HTML Code:

text = "hi\n lol hi new line\n again";

fragman85 04-09-2009 09:13 PM

Quote:

Originally Posted by [email protected] (Post 1482576)
Or you can use
HTML Code:

text = "hi\n lol hi new line\n again";

That's also how linebreaks get saved in DBs btw. :o


All times are GMT +2. The time now is 08:27 AM.

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