Jump to content
  • entries
    4
  • comments
    2
  • views
    3,665

About this blog

Since there are many threads and questions about GUI Widgets i will be working on some tutorials for you guys.
I choose to do this via a blog which will be easier for me to add and make changes to it.

We will start with basic creation of the GUI.
We will then be adding widgets to it and properly using them.
We will then be adding a custom widget.
Lastly i will show some basic fixes to the default widget scripts.

Entries in this blog

Custom Widgets

Remember that a widget's behaviour is dictated by the script that is attached to it. Well its that simple just use a custom script for your widget and your done. I will show you how to create a simple ColorLabel. First copy the default Label.lua script and rename it to Colorlabel.lua Now lets make some changes in your Colorlabel.lua so open it up. We will add 2 variables to the script called bordercolor and textcolor they will be of type Vec4(). Script.bordercolor = Vec4(0.2,0.2,0

GorzenDev

GorzenDev

Basic GUI Creation

Bare with me im not a very good story teller  . I will not be focusing on basic leadwerks usage and assume the reader knows a thing or 2 about leadwerks. So lets start with the basics, Create a window and context. bool App::Start() { window = Leadwerks::Window::Create("GUI Tutorial", 0, 0, 1024, 768); context = Leadwerks::Context::Create(window); return true; } bool App::Loop() { if (window->Closed() || window->KeyHit(Key::Escape)) return false; return true; } Now

GorzenDev

GorzenDev

Default Script Fixes

There is a problem with the default TextArea.lua widget script. Your game will crash when you click on an empty TextArea. Fix: look for the Function "Script:GetCaretCoord(caret)" after: local text = self.lines[self.currentline]--self.widget:GetText() add: if text == nil then return 0 end     More will be added when/if discovered...

GorzenDev

GorzenDev

Adding/Using Widgets

Previously we created a custom class and a basic GUI. Now its time to add some basic widgets to our class and show how to use them.   Lets start with a simple Panel that has a Label, a TextField and a Button. // UI_Interface.h Widget* panel = NULL; Widget* label = NULL; Widget* textField = NULL; Widget* button = NULL; // UI_Interface.cpp //create gui //.... // //panel = Widget::Panel(guiScale * 100, guiScale * 100, guiScale * 300, guiScale * 80, gui->GetBase()); panel = Widge

GorzenDev

GorzenDev

×
×
  • Create New...