News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Working on some kind of menu thing WIP

Started by LemonWizard, October 02, 2009, 01:38:10 PM

Previous topic - Next topic

LemonWizard


Hey everyone!! Yes I'm still here and using playbasic.
This is the latest thing I have going. I spent about two weeks trying to figure out how it would be done logically.

The plan:


A screenshot of the WIP



Explanation of the plan:
I don't want to give too much away yet because I want to be able to show off the first full demo when it's done.
Right now this is a menu shell that feature a dir command (like in dos)
Nothing too fancy it just is able to list files.
It could also be used as the faceplate (code wise) to a text based adventure.
Right now it's the starting of a GUI with a text parsing engine.
Not very far along in this yet.

The main feature right now is well.. I'm trying to get it to parse a loadimage command such as
Loadimage("myimage.bmp")
and by default (For now) it will load the image into a customimage (later will be an array)
and the custom image will by default get drawn onto the main screen.
Later, I'm going to add commands so it can be stretched, blitted, or alpha blended with another image in the same custom images array..

The idea behind this to start was something called visual playbasic. I wanted a real time interpreter... but I also want it to be a tool I can use. And then later I'm going to stick a pretty faceplate on this sucker, optimize the code and turn it into an automated game creation tool (That hopefully), can output automatededly generated code, into a text file which can then be opened and run with playbasic... It's going to be wicked! And, to note. I have NEVER done anything like this before.

Current progress:
Stuck on trying to get it to load an image through the GUI. can't figure out what I'm doing wrong.

Anyone wanna help?
I'll post the code.


; PROJECT : menu1system
; AUTHOR  : LemonWizard
; CREATED : 9/30/2009
; EDITED  : 10/2/2009
; ---------------------------------------------------------------------
;controls variables
#include "Input"
x=100
y=100
xsize=30
ysize=30
windowx=0
windowy=0
windowxsize=100
windowysize=100
loaded=false ;custom image is loaded flag
customimage=newfximage(100,100)
textcol=Rgb(0,255,0)
subscreentextindex=1
mainscreentextindex=1
mainscreen=newfximage(640, 480)
subscreen=newfximage(640, 100)
gosub arraysets
rendertoimage mainscreen
cls rgb(200, 0, 100)
rendertoscreen

goto main

arraysets:
dim subscreentext$(100)
dim mainscreentext$(100)
return

mainscreentext:
for temp=1 to 100
text 5, temp*8, mainscreentext$(temp)
next temp
return

subscreentext:
for temp=subscreentextindex to 100
text 5, (488)+temp*8, subscreentext$(temp)
next temp
return

mainscreentextbump:
dim temparray$(100)
for temp=1 to 100
temparray$(temp-1)=mainscreentext$(temp)
next temp
for temp=1 to 100
mainscreentext$(temp)=temparray$(temp)
if mainscreentext$(temp)="" then mainscreentext$(temp)=" "
next temp
return

mainscreencontents:
rendertoimage mainscreen
cls rgb(100, 255, 100)
rendertoscreen
return

subscreencontents:
rendertoimage subscreen
cls rgb(100, 100, 100)
rendertoscreen
return

drawwindows:
draw_border(0,0, 640, 480)
draw_border(0,480, 640, 100)
return

drawmainscreen:
rendertoimage mainscreen
if loaded=1 then drawimage customimage, 0, 0, 0
rendertoscreen
drawimage mainscreen, 0, 0, 0
return

drawsubscreen:
drawimage subscreen, 0, 480, 0
return

drawmousecoordinates:
rendertoscreen
ink rgb(32, 150, 255)
mx=mousex()
my=mousey()
setcursor 660, 16
print "Mouse x"
setcursor 660, 32
print mx
setcursor 660, 48
print "Mouse y"
setcursor 660, 64
print my
setcursor 660, 80
print "WindowX Custom"
setcursor 660, 96
print windowx
setcursor 660, 112
print "WindowY Custom"
setcursor 660, 128
print windowy
setcursor 660, 144
print "WindowXsize Custom"
setcursor 660, 160
print windowxsize
setcursor 660, 176
print "WindowYsize Custom"
setcursor 660, 192
print windowysize
setcursor 660, 208
print "Current Path"
setcursor 660, 224
print path$
if leftmousebutton()
for temp=1 to 5
ink rgb(255, 0, 0)
circle mx, my, temp*2, 0
next temp
endif
return

setrgb:
ink textcol
return

getinput:
waitnokey
setcursor 8, 500
mine$=StaticInput("Type your message@>")
mainscreentext$(mainscreentextindex)=mine$
mainscreentextindex=mainscreentextindex+1

if mainscreentextindex=100
for temp=1 to 100
gosub mainscreentextbump
next temp
mainscreentextindex=1
endif
rendertoscreen
return

drawcustomwindow:
rendertoimage mainscreen
draw_border(windowx, windowy, windowxsize, windowysize)
rendertoscreen
return


main:
gosub mainscreencontents
gosub subscreencontents
gosub drawcustomwindow
gosub drawmainscreen
gosub drawsubscreen
gosub drawwindows
gosub setrgb
gosub mainscreentext
gosub subscreentext
gosub drawmousecoordinates
gosub parseinput
if spacekey() then gosub getinput

if rightmousebutton() then gosub mainscreentextbump

subscreentext$(5)="         TEST!"

sync
cls rgb(0,0,0)
goto main


function draw_border(x1, y1, xsize, ysize)
setrgbx()
x2=x1+xsize
y2=y1+ysize
box x1, y1, x2, y1+4, 1
box x1, y2, x2, y2-4, 1
box x1, y1, x1+4, y2, 1
box x2, y1, x2-4, y2, 1
line x1, y1, x2, y1
line x1, y1, x1, y2
line x2, y1, x2, y2
line x1, y2, x2, y2
ENDFUNCTION


function setrgbx()
ink rgb(0, 0, 255)
ENDFUNCTION

parseinput:
if mainscreentextindex >1
b$=mainscreentext$(mainscreentextindex-1)
length=len(b$)
if mid$(b$, parsetemp, 10)="new_window"
ind=12
windowx=val(mid$(b$, ind, 3))
ind=ind+4
windowy=val(mid$(b$, ind, 3))
ind=ind+4
windowxsize=val(mid$(b$, ind, 3))
ind=ind+4
windowysize=val(mid$(b$, ind, 3))
endif

;new_window(100,100,200,200)




if mid$(b$, parsetemp, 3)="dir"
mainscreentext$(mainscreentextindex+1)=currentdir$()
mainscreentextindex=mainscreentextindex+2
gosub listdir
endif

if mid$(b$, parsetemp, 8)="bluetext" then textcol=rgb(0, 0, 255)
if mid$(b$, parsetemp, 7)="redtext" then textcol=rgb(255, 0, 0)
if mid$(b$, parsetemp, 9)="greentext" then textcol=rgb(0,255,0)
if mid$(b$, parsetemp, 12)=("loadimage(")
length=len(b$)
path$=mid$(b$, parsetemp+12, length)+".bmp"
print path$

customimage=loadnewfximage(currentDir$()+Path$)
loaded=true
endif
;loadnewimage
;loadimage("testimage(
endif

return

listdir:
ThisDIr$ = CurrentDir$()
  ReadDir ThisDIr$,"",0,1
 
  For Files=0 To GetDirSize()-1
     If GetDirFileType(files)=1
       mainscreentext$(mainscreentextindex)=GetDirFile$(files)
       mainscreentextindex=mainscreentextindex+1
     EndIf
  Next
  mainscreentextindex=mainscreentextindex+1
  return




[/color][/font]