Jump to content

What is the best GUI one can make using the Indie version?


RygtY
 Share

Recommended Posts

I really want to buy the Indie on Steam right now seeing how it is on sale and having tried the demo for a bit it looks promising.

 

But I want to really want to know how good can one make the GUI of a game using just the tools provided with the Indie version?

 

Some games can work with almost no GUI but other games require some fairly large amount of information and buttons to be accessible at all times.

 

I've searched the internet for tutorials and examples, but there doesn't seem to be any.

 

Also I was rather saddened that FlowGUI is no longer being worked on seeing how that had great promise for people who have to work with the Indie version for whatever reasons.

 

EDIT: Ok perhaps I should clarify my point.

 

It isn't about how good in terms of aesthetics but in terms of possible different elements one can put on the screen.

 

I figured out in theory how to create a button, checkbox, or radio button using Lua alone.

 

But for something like scrollpanes and dropdown menus I might need to use C++ and/or GUI building plugins.

Link to comment
Share on other sites

Ok I think I might know how to eliminate the need for scrollpanes and dropdown menus in some cases.

 

Also I'll admit most of my experience with GUIs come from Java and how it had classes for many different GUI elements. Buttons, radio buttons, checkboxes, textboxes, scrollpanes, etc.

 

So as you can imagine I'm currently experiencing some distress as I've never worked on making a GUI without such convenience.

Link to comment
Share on other sites

Lua can simulate classes.

 

Look in the Scripts folder and open up AnimationManager.lua and you'll see how to simulate classes. To give the same setup but a little less detail here is a basic class file.

 

-- if this lua file gets included multiple times this will bail out saying it's already been defined. defining twice doesn't really hurt anything but why do it right
if ClassName ~= nil then return end

-- define a lua table that will act as our class
ClassName = {}

-- define our ctor with parameters
function ClassName:Create(param1, param2)
  -- create a local table, fill it in with variables, copy ClassName functions to it, then return it. this is our new instance of ClassName that the user will work with
  local obj = {}

  -- create variables/properties of this object instance
  obj.param1 = param1
  obj.param2 = param2

  -- copy the ClassName functions to this local object instance so it can use them
  local k,v
  for k,v in pairs(ClassName) do
     obj[k] = v
  end

  return obj;
end

-- example of a class method
function ClassName:Update()
  -- self is the same as 'this' in other languages and refers to the instance created with the ctor. unlike other languages you MUST use self. to prefix all instance variables
  print(self.param1)
end

 

So in Lua functions are just variables so they can be passed around and stored just like a variable and called back at a later time. This is handy for callbacks for widget events.

 

function MyClickHandler()
end

 

is the same as

 

MyClickHandler = function() 
end

 

So you can do something like:

 

function btnExit_OnClick()
end

button = Button:Create("btnExit", "Exit", 100, 100, 200, 50)
button.onClick = btnExit_OnClick

 

You will most likely want your event handler to be a Leadwerks Script object function so you can easily access other Script level variables. In that case you have to pass the Scripts 'self' plus the Scripts function and store both in your widget. Then call them back. So would be handy to make another "class" called like EventHandler that takes both the 'self' object and a function.

 

function EventHandler:Create(obj, func)
  local obj = {}

  obj.obj = obj
  obj.func = func

  -- copy function code here just like above

  return obj
end

function EventHandler:Raise()
  -- this is how you call a stored function that is part of another "class". you call the func passing in the object itself which is why we can use 'self' inside that function. lua hides the 'self' parameter when the class function is defined like 'function Script:OnClick()'. see no 'self' parameter defined but it's there because of defining the function with ':'. it's a nice lua trick
  self.func(self.obj)
end

 

Hope that helps

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...