Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rouge line breaks
#1
I'm having trouble with a program I'm working on. This is a file editing type program designed to design a file for a game I'm working on. It's far from done, and I'm stuck.

First, a summary of what is does: You make, delete, edit, and rearrange commands that will be saved to a file and used in a game as instructions on a conversation. This is modelled after a the trigger editor in Warcraft III if any of you know what that is (probably not though... All of you seem too mature.) As of now, I have four commands: set color, display text, wait for key press, and clear screen, all of which are interpreted in the game I made.


The part I'm having trouble with is the editing of displaying text. It edits the string, but shifts the whole screen up. I don't know what else to say... Can anyone help? Here is the code.

Code:
DECLARE FUNCTION gettext$ (theString$)
DECLARE SUB cleanupbottom ()
DECLARE SUB edit (index!)
DECLARE SUB shiftrangeup (top!, bottom!)
DECLARE SUB delete (index!)
DECLARE SUB shiftdown (which!)
DECLARE SUB shiftup (which!)
DECLARE FUNCTION numcommands! ()
DECLARE SUB dispmenu (x!, y!)
DECLARE FUNCTION valueof$ (thing AS STRING)
DECLARE SUB dispcoms (x!, y!, selected!)
DECLARE FUNCTION parsefordisp$ (toparse AS STRING)
DIM SHARED comm$(100)
DIM SHARED argument$(100)
selected = 1
comm$(1) = "setcolor"
argument$(1) = "4"
comm$(2) = "disptext"
argument$(2) = "And the Panda o' Doom reigns over the land"
comm$(3) = "wait"
argument$(3) = ""
comm$(4) = "deeaatthh"
argument$(4) = "moo?"
comm$(5) = "clear"
argument$(5) = ""


DO
        IF press$ = CHR$(0) + CHR$(80) AND selected < numcommands THEN selected = selected + 1
        IF press$ = CHR$(0) + CHR$(72) AND selected > 1 THEN selected = selected - 1
        IF LCASE$(press$) = "u" AND selected > 1 THEN CALL shiftup(selected)
        IF LCASE$(press$) = "d" AND selected < numcommands THEN CALL shiftdown(selected)
        IF LCASE$(press$) = "t" THEN CALL delete(selected)
        IF LCASE$(press$) = "e" THEN CALL edit(selected)


        CLS
        CALL dispmenu(70, 1)
        CALL dispcoms(1, 1, selected)
      
        DO: press$ = INKEY$: LOOP WHILE press$ = ""
LOOP

SUB cleanupbottom
LOCATE 22, 1
PRINT "                                                                              "
PRINT "                                                                              "
END SUB

SUB delete (index)
CALL shiftrangeup(index, numcommands)
comm$(numcommands) = "": argument$(numcommands) = ""
END SUB

SUB dispcoms (x, y, selected)
i = 1
COLOR 8, 7
LOCATE x, y
PRINT "Command        Argument"
COLOR 0, 0
DO WHILE comm$(i) <> ""
        IF i = selected THEN COLOR 15, 0 ELSE COLOR 7, 0
        IF comm$(i) = "setcolor" THEN
                LOCATE y + i, x
                PRINT "Set Color:"
                LOCATE y + i, x + 15: COLOR 4, VAL(argument$(i)): PRINT "  "
        ELSEIF comm$(i) = "disptext" THEN
                PRINT "Display Text:"
                LOCATE y + i, x + 15: PRINT parsefordisp$(valueof$(argument$(i)))
        ELSEIF comm$(i) = "wait" THEN
                PRINT "Wait for key press"
        ELSEIF comm$(i) = "clear" THEN
                PRINT "Clear screen"
        ELSE
                IF selected <> i THEN COLOR 8
                PRINT "Command not recognized"
        END IF

        i = i + 1
LOOP
END SUB

SUB dispmenu (x, y)
LOCATE y, x: COLOR 15, 0: PRINT "N"
LOCATE y, x + 1: COLOR 7, 0: PRINT "ew"

LOCATE y + 1, x: COLOR 7, 0: PRINT "Dele"
LOCATE y + 1, x + 4: COLOR 15, 0: PRINT "t"
LOCATE y + 1, x + 5: COLOR 7, 0: PRINT "e"

LOCATE y + 2, x: COLOR 15, 0: PRINT "E"
LOCATE y + 2, x + 1: COLOR 7, 0: PRINT "dit"

LOCATE y + 3, x: COLOR 7, 0: PRINT "Move "
LOCATE y + 3, x + 5: COLOR 15, 0: PRINT "D"
LOCATE y + 3, x + 6: COLOR 7, 0: PRINT "own"

LOCATE y + 4, x: COLOR 7, 0: PRINT "Move "
LOCATE y + 4, x + 5: COLOR 15, 0: PRINT "U"
LOCATE y + 4, x + 6: COLOR 7, 0: PRINT "p"

END SUB

SUB edit (index)
IF comm$(index) = "setcolor" THEN
        FOR i = 1 TO 7
                LOCATE 23, 18 + i * 5: COLOR 0, i: PRINT "     "
        NEXT i
        sel = 1
        COLOR 15
        DO
                LOCATE 22, 15 + sel * 5: COLOR 15, 0: PRINT " "
                LOCATE 22, 20 + sel * 5: COLOR 15, 0: PRINT "ê"
                LOCATE 22, 25 + sel * 5: COLOR 15, 0: PRINT " "
                DO: press$ = INKEY$: LOOP WHILE press$ = ""
                IF press$ = CHR$(0) + CHR$(77) AND sel < 7 THEN sel = sel + 1
                IF press$ = CHR$(0) + CHR$(75) AND sel > 1 THEN sel = sel - 1
                IF press$ = CHR$(13) THEN EXIT DO
        LOOP
        argument$(index) = STR$(sel)
ELSEIF comm$(index) = "disptext" THEN
        
        argument$(index) = gettext$(argument$(index))
        'argument$(index) = "THIS is edited"
END IF

CALL cleanupbottom
END SUB

FUNCTION gettext$ (theString$)
maxcp = 75
cp = LEN(theString$)
LOCATE 22, 1
PRINT (theString$ + "_")
DO
        DO: press$ = INKEY$: LOOP WHILE press$ = ""
        IF press$ = CHR$(8) THEN
                IF LEN(theString$) > 0 THEN
                        theString$ = MID$(theString$, 1, LEN(theString$) - 1)
                        cp = cp - 1
                        LOCATE 22, cp + 1: PRINT ("_ ")
                END IF
        ELSE
                theString$ = theString$ + press$
                cp = cp + 1
                IF cp > maxcp + 1 THEN cp = cp - 1
                LOCATE 22, cp: PRINT (press$ + "_")
        END IF
LOOP WHILE press$ <> CHR$(13)
gettext$ = theString$
END FUNCTION

FUNCTION numcommands
i = 1
DO WHILE comm$(i) <> ""
        i = i + 1
LOOP
numcommands = i - 1
END FUNCTION

FUNCTION parsefordisp$ (toparse AS STRING)
        IF LEN(toparse) > 40 THEN toparse = CHR$(34) + MID$(toparse, 1, 40) + "..." + CHR$(34)
        parsefordisp$ = toparse
END FUNCTION

SUB shiftdown (which)
SWAP comm$(which), comm$(which + 1)
SWAP argument$(which), argument$(which + 1)
which = which + 1
END SUB

SUB shiftrangeup (top, bottom)
IF top > bottom THEN SWAP top, bottom
FOR i = top + 1 TO bottom
        comm$(i - 1) = comm$(i)
        argument$(i - 1) = argument$(i)
NEXT i
END SUB

SUB shiftup (which)
SWAP comm$(which), comm$(which - 1)
SWAP argument$(which), argument$(which - 1)
which = which - 1

END SUB

FUNCTION valueof$ (thing AS STRING)
'This is used so it doesn't directly access an array member, which changes it
valueof$ = thing
END FUNCTION
Reply


Messages In This Thread
Rouge line breaks - by Dark Conundrum - 05-24-2003, 07:02 AM
Rouge line breaks - by Agamemnus - 05-24-2003, 07:32 AM
Rouge line breaks - by wizardlife - 05-24-2003, 07:33 AM
Rouge line breaks - by Dark Conundrum - 05-26-2003, 08:25 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)