Author Topic: Messing with the UI (Pilchard123!)  (Read 2794 times)

0 Members and 1 Guest are viewing this topic.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Messing with the UI (Pilchard123!)
« on: January 02, 2011, 09:46:50 PM »
Been experimenting with doing UI from lua the last twenty minutes. Seeing what it's possible to achieve.

luanet guide (see section on subtypes) http://luainterface.googlecode.com/svn/trunk/luainterface/doc/guide.pdf

Here's some stuff to go on.

LUA:
Code: [Select]
Game = luanet.import_type("Eufloria.Game")
luanet.load_assembly("System.Drawing")
luanet.load_assembly("Wuwei")
Rectangle = luanet.import_type("System.Drawing.Rectangle")
Window = luanet.import_type("Wuwei.UI.Window")
myWindow = Window(Game.UI, nil, Rectangle(0,0,300,300))
Game.UI.AddWindow(myWindow)

myWindow.Title="My window"
myWindow.CentreTitle=true
myWindow.TitleTextSize=2
myWindow.AlwaysOnTop = true
myWindow.Moveable = false
myWindow.HasCloseButton=false
myWindow.HasHideButton=true
myWindow.Resizeable=false

Here is c# code for the dialog boxes used in the game, should be possible to sort out something like this using luanet
(click to show/hide)

« Last Edit: January 02, 2011, 09:49:54 PM by Alex »

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Re: Messing with the UI (Pilchard123!)
« Reply #1 on: January 02, 2011, 09:54:24 PM »
So if you

- import the types Wuwei.UI.UiEventArgs, Wuwei.UI.Button, Wuwei.UI.Window and probably a bunch of other stuff
- create your own uieventargs subtypes
- create your own window subtype
- add some buttons
- ? override some of the methods with your own lua code ? - this would be ideal , if not i guess you could somehow make the buttons create results you could peek like in the dialog example

you should be able to have a somewhat functioning UI...

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Re: Messing with the UI (Pilchard123!)
« Reply #2 on: January 02, 2011, 09:55:40 PM »
Worth messing with all this stuff in the console btw to speed up turnaround, until you're ready to stick it into a level. I found it quicker anyway.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Messing with the UI (Pilchard123!)
« Reply #3 on: January 02, 2011, 10:25:16 PM »
This looks excellent :>


I will let Pilchard have first shout with this stuff, seeing as he is likely to get the most benefit.  I've anyway got enough on my plate already.  :p

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Re: Messing with the UI (Pilchard123!)
« Reply #4 on: January 02, 2011, 11:03:33 PM »
I wonder what else I have exposed that can be exploited for fun and profit...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Messing with the UI (Pilchard123!)
« Reply #5 on: January 02, 2011, 11:05:17 PM »
Empire colour?
(i'm so predictable..)

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035
Re: Messing with the UI (Pilchard123!)
« Reply #6 on: January 02, 2011, 11:19:33 PM »
Empire colour?
(i'm so predictable..)
Ah... nope. Sorry! :( I'll make a note to add this next time.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Messing with the UI (Pilchard123!)
« Reply #7 on: January 02, 2011, 11:24:51 PM »
hehe, no worries.  :>

I might still manage to hack something together to change the empire number until a desired colour is reached, when I get finished with my current project.  I recall you showed me some commands in another thread that might let you read the RGB values of an existing empire...
So really there is no rush on it.  :>

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Messing with the UI (Pilchard123!)
« Reply #8 on: January 02, 2011, 11:33:20 PM »
Is it possible to make the DrawSprite() function draw things so that they are behind asteroids using this new stuff?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Messing with the UI (Pilchard123!)
« Reply #9 on: January 03, 2011, 12:16:44 AM »
(this would solve all my efficiency problems instantly..)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: Messing with the UI (Pilchard123!)
« Reply #10 on: January 03, 2011, 10:12:22 AM »
My head hurts. I know nothing about any version of C, but I'll have a look at it.

Annikk, don't hold back on my account, I probably won't be able to do anthing with this for quite a while.


EDIT: The stuff in the code box up the top goes where, exactly? LevelSetup? LevelLogic? Before LS? Anywhere?

Also, what is it supposed to do?


EDIT 2: I can't find anything related to luanet on my computer except in the PDF that you linked up top. Problem or not?
« Last Edit: January 03, 2011, 10:40:11 AM by Pilchard123 »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Messing with the UI (Pilchard123!)
« Reply #11 on: January 03, 2011, 10:39:00 AM »
Try LevelSetup :>
By the looks of it, it just makes a blank box or window.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: Messing with the UI (Pilchard123!)
« Reply #12 on: January 03, 2011, 10:48:59 AM »
That's what I thought it did, but if I put it in LS or before it, it complains about [string "chunk"]:1:invalid arguments to method: UI.Addwindow. If I put it in LL, it loads my basic map (the same as for all my demo/test maps) with no problems, but also no window...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Messing with the UI (Pilchard123!)
« Reply #13 on: January 03, 2011, 10:57:21 AM »
Did you definitely copy this line in?
Code: [Select]
Game = luanet.import_type("Eufloria.Game")


If you did, hmm, I'm not sure...
Try moving the line "Game.UI.AddWindow(myWindow)" below the rest of the new code mayhaps.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: Messing with the UI (Pilchard123!)
« Reply #14 on: January 03, 2011, 11:04:47 AM »
Yes, I did copy that in, and moving the AddWindow line doesn't help, either.

Using DrawBox(2,6,8,3) leads to the error [string "chunk"]:1:invalid arguments to method call, which leads me to believe that there are either too many/few arguments to Game.UI.AddWindow() or it hasn't been made properly, I think most likely the former.