Here's the full code:
Rem Project: Isometric Tile and Map Editor
Rem Created: Sunday, September 25, 2011
Rem ***** Main Source File *****
SET DISPLAY MODE 800, 600, 32
SYNC ON : SYNC RATE 60
DRAW SPRITES FIRST
// USER DEFINED TYPES
TYPE Image
img_num AS DWORD
img_marker AS STRING
img_filename AS STRING
ENDTYPE
TYPE MapElement
sprite_num AS DWORD
sprite_x AS INTEGER
sprite_y AS INTEGER
sprite_priority AS DWORD = 0
img_num AS DWORD
ENDTYPE
// SET GLOBAL VARIABLES:
GLOBAL load_image_pressed = 0
GLOBAL top_of_image_list = 0
GLOBAL top_of_sprite_list = 0
GLOBAL currently_selected_image = -1
GLOBAL currently_selected_sprite = -1
GLOBAL canvas_x = 0
GLOBAL canvax_y = 0
GLOBAL background_image AS DWORD
GLOBAL background_sprite AS DWORD
GLOBAL background_sprite_priority AS DWORD = 1 // Necessary now since the editor background is a sprite
// Canvas shift commands (for scrolling through the map)
GLOBAL cx_shift = 0
GLOBAL cy_shift = 0
DIM image_list(0) AS Image // List of images
EMPTY ARRAY image_list(0)
DIM sprite_list(0) AS MapElement // List of sprites to be drawn on map
EMPTY ARRAY sprite_list(0)
// GET BACKGROUND IMAGE FOR EDITOR & SET UP TRANSPARENCY
SET IMAGE COLORKEY 255, 0, 255
background_image = Get_Free_Image()
LOAD IMAGE "media\editor_template.bmp", background_image
background_sprite = Get_Free_Sprite()
SPRITE background_sprite, 0, 0, background_image
SET SPRITE PRIORITY background_sprite, background_sprite_priority
// OUR MAIN LOOP
DO
//IF load_image_pressed = 1
// Load_Image_Window()
// GOTO end_of_loop
//ENDIF
Normal_Window()
end_of_loop:
SYNC
LOOP
FUNCTION Get_Free_Image()
i = 1
REPEAT
i = i + 1
UNTIL IMAGE EXIST(i) = 0
ENDFUNCTION i
FUNCTION Get_Free_Sprite()
i = 1
REPEAT
i = i + 1
UNTIL SPRITE EXIST(i) = 0
ENDFUNCTION i
FUNCTION Load_Image_Window()
//HIDE ALL SPRITES
CLS RGB(0,0,0)
INK RGB(255,255,255),RGB(0,0,0)
//filename$ = Text_Prompt(0,0, "Enter filename: ")
//refname$ = Text_Prompt(0, TEXT HEIGHT("A"), "Enter reference name: ")
Input "Enter filename: ", filename$
Input "Enter reference name: ", refname$
IF FILE EXIST(filename$) = 1
ARRAY INSERT AT BOTTOM image_list(0)
max_items = ARRAY COUNT(image_list(0))
image_list(max_items).img_filename = filename$
image_list(max_items).img_marker = refname$
//Input "Enter filename: ", image_list(max_items).img_filename
//Input "Enter reference name: ", image_list(max_items).img_marker
image_list(max_items).img_num = Get_Free_Image()
LOAD IMAGE image_list(max_items).img_filename, image_list(max_items).img_num
ELSE
TEXT 0, 0, "Error: File doesn't exist!"
SYNC
WAIT KEY
ENDIF
load_image_pressed = 0
//SHOW ALL SPRITES
ENDFUNCTION
FUNCTION Normal_Window()
SHOW ALL SPRITES
libp AS DWORD = 0
INK RGB(0,0,0),RGB(128,128,128)
SPRITE background_sprite, 0, 0, background_image
SET TEXT FONT "terminal" : SET TEXT SIZE 18 : SET TEXT TRANSPARENT
TEXT 0, 0, "MOUSE X,Y : "+Str$(MOUSEX())+","+Str$(MOUSEY())
TEXT (800-TEXT WIDTH( "Currently selected image: "+Str$(currently_selected_image))), 582, "Currently selected image: "+Str$(currently_selected_image)
Draw_Canvas()
IF ARRAY COUNT(image_list(0)) > -1
Draw_Image_List()
ENDIF
IF ARRAY COUNT(sprite_list(0)) > -1
Draw_Sprite_List()
ENDIF
libp = Text_Button(0, 22, "LOAD IMAGE")
IF libp = 1 THEN Load_Image_Window()//load_image_pressed = 1
ENDFUNCTION
FUNCTION Text_Button(x_pos AS DWORD, y_pos AS DWORD, txt AS STRING)
button_pressed = 0
text_width = TEXT WIDTH(txt)
text_height = TEXT HEIGHT(txt)
SET TEXT OPAQUE
TEXT x_pos,y_pos, txt
IF (MOUSEX() >= x_pos) AND (MOUSEX() <= x_pos+text_width)
IF (MOUSEY() >= y_pos) AND (MOUSEY() <= y_pos+text_height)
IF MOUSECLICK() = 1
INK RGB(0, 255,0),RGB(100,100,100)
TEXT x_pos,y_pos, txt
button_pressed = 1
ENDIF
ENDIF
ENDIF
ENDFUNCTION button_pressed
FUNCTION Text_Prompt(x_pos AS DWORD, y_pos AS DWORD, txt AS STRING)
//INK RGB(255, 255, 255), RGB(0,0,0)
//SET TEXT OPAQUE
instr AS STRING
x AS DWORD = 0
CLEAR ENTRY BUFFER
REPEAT
instr = ENTRY$(1)
TEXT x_pos, y_pos, txt + instr
IF RETURNKEY() = 1
WAIT 1000
x = 1
ENDIF
SYNC
UNTIL x = 1
ENDFUNCTION instr
FUNCTION Draw_Image_List()
cur_y = 44
i = 0
visible_count = 0
max_items = ARRAY COUNT(image_list(0))
For i = top_of_image_list TO max_items
TEXT 0, cur_y, image_list(i).img_marker
//Check if list item is clicked on
IF (MOUSEX() >= 0) AND (MOUSEX() < 142)
IF (MOUSEY() >= cur_y) AND (MOUSEY() <= (cur_y+TEXT HEIGHT(image_list(i).img_marker)))
IF MOUSECLICK() = 1
//SET CLICKED ITEM TO CURRENTLY SELECTED ITEM AND ALLOW FOR PUTTING ON CANVAS
currently_selected_image = i
ENDIF
ENDIF
ENDIF
// Increase Y for next list item
cur_y = cur_y+TEXT HEIGHT(image_list(i).img_marker)
Next
ENDFUNCTION
FUNCTION Draw_Sprite_List()
cur_y = 22
i = 0
visible_count = 0
max_items = ARRAY COUNT(sprite_list(0))
For i = top_of_sprite_list TO max_items
TEXT 678, cur_y, "sprite("+Str$(i)+")"
//Check if list item is clicked on
IF (MOUSEX() >= 678) AND (MOUSEX() < 800)
IF (MOUSEY() >= cur_y) AND (MOUSEY() <= (cur_y+TEXT HEIGHT("sprite("+Str$(i)+")")))
IF MOUSECLICK() = 1
currently_selected_sprite = i
ENDIF
ENDIF
ENDIF
// Increase Y for next list item
cur_y = cur_y+TEXT HEIGHT("sprite("+Str$(i)+")")
Next
ENDFUNCTION
// NOTE: TO GET SCREEN COORDINATES FROM CANVAS COORDINATES:
// screen_x = (canvas_x+cx_shift) - 135
// screen_y = (canvas_y+cy_shift) - 21
//
// TO GET CANVAS COORDINATES FROM SCREEN COORDINATES:
// canvas_x = screen_x + 135 - cx_shift
// canvas_y = screen_y + 21 - cy_shift
FUNCTION Draw_Canvas()
max_sprites = ARRAY COUNT(sprite_list(0))
IF max_sprites > -1
FOR i = 0 TO max_sprites
SPRITE sprite_list(i).sprite_num, Get_Screen_X(sprite_list(i).sprite_x), Get_Screen_Y(sprite_list(i).sprite_y), sprite_list(i).img_num
SHOW SPRITE sprite_list(i).sprite_num
//SET SPRITE sprite_list(i).sprite_num,0,1
//PASTE SPRITE sprite_list(i).sprite_num, Get_Screen_X(sprite_list(i).sprite_x), Get_Screen_Y(sprite_list(i).sprite_y)
NEXT
ENDIF
IF (MOUSEX() >= 135) AND (MOUSEX() <= 674)
IF (MOUSEY() >= 21) AND (MOUSEY() <= 579)
canvas_x = Get_Canvas_X(MOUSEX())
canvas_y = Get_Canvas_Y(MOUSEY())
TEXT 136, 582, "CANVAS X, Y: "+Str$(canvas_x)+","+Str$(canvas_y)
IF MOUSECLICK() = 1
// Place sprite at location
IF currently_selected_image > -1
ARRAY INSERT AT BOTTOM sprite_list()
ARRAY INDEX TO BOTTOM sprite_list()
sprite_list().sprite_num = Get_Free_Sprite()
sprite_list().sprite_x = canvas_x
sprite_list().sprite_y = canvas_y
sprite_list().img_num = image_list(currently_selected_image).img_num
SPRITE sprite_list().sprite_num, Get_Screen_X(sprite_list().sprite_x), Get_Screen_Y(sprite_list().sprite_y), image_list(currently_selected_image).img_num
ENDIF
ENDIF
IF MOUSECLICK() = 2
// Check to see if mouseclick lies in bounding-box of any of the sprites placed, and if so select that sprite to show properties.
IF max_sprites > -1
FOR i = 0 TO MAX_SPRITES
`IF (MOUSE_X >= sprite_list(i).sprite_x)
NEXT
ENDIF
ENDIF
ENDIF
ENDIF
ENDFUNCTION
FUNCTION Get_Canvas_X(screen_x AS INTEGER)
canvas_x = cx_shift+screen_x - 135
ENDFUNCTION canvas_x
FUNCTION Get_Canvas_Y(screen_y AS INTEGER)
canvas_y = cy_shift+screen_y - 21
ENDFUNCTION canvas_y
FUNCTION Get_Screen_X(canvas_x AS INTEGER)
screen_x = canvas_x + 135 - screen_x
ENDFUNCTION screen_x
FUNCTION Get_Screen_Y(canvas_y AS INTEGER)
screen_y = canvas_y + 21 - screen_y
ENDFUNCTION screen_y
And all I'm trying to do is get a text form of input, which INPUT isn't playing nicely when I draw sprites. Attached is the editor template file needed for this.
Thanks...