Author Topic: My questions page about making GUIs  (Read 1118 times)

I am in the process of making a newspaper-looking GUI for my upcoming event-based CRPG, and while making it, Blockland crashed.  When I restarted Blockland, either in correlation with or not, my saved "NewspaperGui" was not in the menu for GUI select.  I have the "NewspaperGui.Gui" saved in the base/client/ui/ folder, is this where it should be to load in the GUI select menu of the GUI maker?  If so, where?  If not, then what did I do wrong?

This would be my first serious GUI I have/am making, so I don't know much about the process of saving them and the correct place I should put them.

Answer: Everytime you work on your GUI, you have to execute it by typing exec("base/client/ui/NewspaperGui.gui"); into the console, unless it is in an addon.



Second question.

I have made a test gui to see what I need to enter to keybind the gui and such.

File directory: Add-Ons/Client_CRPG/
In that folder, I have "NewspaperGui.gui", "Client.cs", "description.txt", and "Newspaper.png"


Code: [Select]
//NewspaperGui.gui
//--- OBJECT WRITE BEGIN ---
new GuiControl(Newspaper) {
   profile = "GuiDefaultProfile";
   horizSizing = "right";
   vertSizing = "bottom";
   position = "0 0";
   extent = "1024 768";
   minExtent = "8 2";
   enabled = "1";
   visible = "1";
   clipToParent = "1";

   new GuiWindowCtrl() {
      profile = "GuiWindowProfile";
      horizSizing = "center";
      vertSizing = "bottom";
      position = "307 121";
      extent = "410 432";
      minExtent = "8 2";
      enabled = "1";
      visible = "1";
      clipToParent = "1";
      maxLength = "255";
      resizeWidth = "1";
      resizeHeight = "1";
      canMove = "0";
      canClose = "1";
      canMinimize = "0";
      canMaximize = "0";
      minSize = "50 50";
      closeCommand = "canvas.popDialog(NewspaperGui.gui);";

      new GuiBitmapCtrl() {
         profile = "GuiDefaultProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "5 27";
         extent = "400 400";
         minExtent = "8 2";
         enabled = "1";
         visible = "1";
         clipToParent = "1";
         bitmap = "./Newspaper";
         wrap = "0";
         lockAspectRatio = "0";
         alignLeft = "0";
         alignTop = "0";
         overflowImage = "0";
         keepCached = "0";
         mColor = "255 255 255 255";
         mMultiply = "0";

         new GuiScrollCtrl(Text1) {
            profile = "GuiScrollProfile";
            horizSizing = "right";
            vertSizing = "bottom";
            position = "13 193";
            extent = "177 95";
            minExtent = "8 2";
            enabled = "1";
            visible = "1";
            clipToParent = "1";
            willFirstRespond = "0";
            hScrollBar = "alwaysOff";
            vScrollBar = "alwaysOff";
            constantThumbHeight = "0";
            childMargin = "0 0";
            rowHeight = "40";
            columnWidth = "30";
         };
         new GuiScrollCtrl(Text2) {
            profile = "GuiScrollProfile";
            horizSizing = "right";
            vertSizing = "bottom";
            position = "209 193";
            extent = "177 95";
            minExtent = "8 2";
            enabled = "1";
            visible = "1";
            clipToParent = "1";
            willFirstRespond = "0";
            hScrollBar = "alwaysOff";
            vScrollBar = "alwaysOff";
            constantThumbHeight = "0";
            childMargin = "0 0";
            rowHeight = "40";
            columnWidth = "30";
         };
      };
   };
};
//--- OBJECT WRITE END ---
function Open_NewspaperGui.gui(%toggle)
{
if(%toggle)
{
if(NewspaperGui.gui.isAwake())
{
canvas.popDialog(NewspaperGui.gui);
}

else
{
canvas.pushDialog(NewspaperGui.gui);
}
}
}

Code: [Select]
//Client.cs
exec("./NewspaperGui.gui");

    $remapDivision[$remapCount] = "Blocky999";
    $remapName[$remapCount] = "NewspaperGui.gui";
    $remapCmd[$remapCount] = "Open_NewspaperGui.gui";
    $remapCount++;

Code: [Select]
//description.txt
Title: CRPG GUIs
Author: Blocky999
Guis for my CRPG

I'm following this as a tutorial.

I started up Blockland, keybound it to "Alt R", started a game, pressed the keybind, nothing happened.  I entered the console and nothing was displayed.  What am I doing wrong?
« Last Edit: June 14, 2013, 09:10:30 PM by Gen. Hothauser »

To get the GUI to be able to be selected in that list execute the .gui file in the console.
exec("base/client/ui/NewspaperGui.gui");

I also suggest reading http://forum.blockland.us/index.php?topic=67198.0 for more info if you haven't already.
« Last Edit: June 09, 2013, 11:35:11 PM by Vaux »

Alright, thank you, I'll check that in the afternoon.

And thanks for the link, I believe I have already seen it, but then again a lot of these look the same.

[EDIT]

Do I need to execute the .gui file every time I make a change to it, or is it a one-time execution?
« Last Edit: June 10, 2013, 12:12:32 AM by Gen. Hothauser »

Do I need to execute the .gui file every time I make a change to it, or is it a one-time execution?
Every time you start Blockland, unless it is packaged in an add-on. (in which case you do not need to do so at all).

Executing the GUI is basically loading it.
exec GUI -> work on it -> save file (I usually overwrite)

But, yes, basically every time you load blockland.

EDIT: Greek, you ninja!
« Last Edit: June 10, 2013, 12:24:30 AM by Vaux »

Alright, thank you guys both.  I'm gunna lock the topic until I have another question.

I'm also trying to start a new trend with these question threads, with the OP including the answer in the post with the question for easy access by others in the future.
« Last Edit: June 10, 2013, 12:33:22 AM by Gen. Hothauser »

Also, the gui editor uses .save("filename"); on the gui, I found that blockland has heavy problems to save files if the file name already exists.
It sometimes doesn't write anything at all!
So when you work on a more complex gui you should be saving it to blahgui1.gui, blahgui2.gui etc unless you like your work being lost for no reason


Bump for second question.

Change every instance of Open_NewspaperGui.gui with just Open_NewspaperGui. Functions cannot contain periods.

For future reference, when you define a function, it's name cannot contain any special characters(underscores are an exception to this rule), it's name also cannot start with any numeric characters.
« Last Edit: June 14, 2013, 11:35:30 PM by Kadon »

Ok thanks, I'll try that in the morning.

Why is the gui in base/client/ui
Put it in your add-on

Why is the gui in base/client/ui
Put it in your add-on

That was with my first question, look at the second question below the divider.

Change every instance of Open_NewspaperGui.gui with just Open_NewspaperGui. Functions cannot contain periods.

What about If statements and canvas.pop/pushdialog?