From 66edee92ae3fa0bda09b7a1c3a5b1f580691e782 Mon Sep 17 00:00:00 2001 From: WALL OF JUSTICE <-> Date: Tue, 8 May 2018 00:36:04 +1000 Subject: [PATCH] + Add help window to editor for most functions. Accessible via help dropdown or pressing H --- src/buttons.cpp | 168 +++++++++++++++++++++++++++-------------- src/editor.cpp | 194 +++++++++++++++++++++++++++++++++++++++++++++++- src/editor.hpp | 3 + 3 files changed, 305 insertions(+), 60 deletions(-) diff --git a/src/buttons.cpp b/src/buttons.cpp index 773e44830..90bdc9609 100644 --- a/src/buttons.cpp +++ b/src/buttons.cpp @@ -52,6 +52,7 @@ button_t* butAttributes; button_t* butClearMap; button_t* butHelp; button_t* butAbout; +button_t* butEditorControls; button_t* butMonsterHelm; button_t* butMonsterWeapon; button_t* butMonsterShield; @@ -1494,63 +1495,15 @@ void buttonAbout(button_t* my) menuVisible = 0; subwindow = 1; - subx1 = xres / 2 - 200; - subx2 = xres / 2 + 200; - suby1 = yres / 2 - 300; - suby2 = yres / 2 + 300; + subx1 = xres / 2 - 160; + subx2 = xres / 2 + 160; + suby1 = yres / 2 - 56; + suby2 = yres / 2 + 56; strcpy(subtext, "Barony: Map Editor v2.4" - "\n\nSee EDITING for full documentation." - "\n\nThis software is copyright 2013 (c)" - "\nSheridan Rathbun, all rights reserved." - "\n\nSee LICENSE for details.\n\n"); - strcat(subtext, "Editor File Shortcuts:\n"); - strcat(subtext, "New Map: CTRL + N\n"); - strcat(subtext, "Open: CTRL + O\n"); - strcat(subtext, "Save: CTRL + S\n"); - strcat(subtext, "Change Load/Save Directory: CTRL + D\n"); - strcat(subtext, "Close Window/Dialogue: CTRL + M\n"); - strcat(subtext, "Delete Text: Backspace or Grave (`)\n"); - - strcat(subtext, "\nEditor Functions:\n"); - strcat(subtext, "Open Sprite Window: S\n"); - strcat(subtext, "Open Tile Window: T\n"); - strcat(subtext, "Sprite Properties: F2\n"); - strcat(subtext, "Map Properties: CTRL + M\n"); - strcat(subtext, "Delete Selected Sprite: DEL\n"); - strcat(subtext, "Cycle Stacked Sprites: C\n"); - - strcat(subtext, "\nNavigation:\n"); - strcat(subtext, "Move Camera/View: Arrow Keys\n"); - strcat(subtext, "Change Current Wall Layer: SHIFT + Scrollwheel\n"); - strcat(subtext, "Change Current Wall Layer: CTRL + U, CTRL + P\n"); - strcat(subtext, "Toggle First Person Camera: F\n"); - - strcat(subtext, "\nTile Palette (Last Used Tiles):\n"); - strcat(subtext, "Cycle Through Current Tile Palette: Scrollwheel\n"); - strcat(subtext, "Cycle Through All Palettes: CTRL + Scrollwheel\n"); - strcat(subtext, "Choose Specific Tile In Palette: Numpad 0-9\n"); - strcat(subtext, "Choose Specific Tile In Palette: Left Click Tile\n"); - strcat(subtext, "Lock Changes to Current Palette: Numpad *\n"); - strcat(subtext, "Go To Next Palette: Numpad +\n"); - strcat(subtext, "Go To Previous Palette: Numpad -\n"); - strcat(subtext, "Clear Tile in Palette: Right Click Tile\n"); - - strcat(subtext, "Editing Tools:\n"); - strcat(subtext, "Pencil: Draws currently selected tile on current wall layer.\n"); - strcat(subtext, " Does not select sprites. Right click sets the selected tile\n"); - strcat(subtext, " under the cursor to selected.\n"); - strcat(subtext, "Point: Selects sprites only. Sprites can be moved or deleted once\n"); - strcat(subtext, " placed and selected with this tool. Left click selects, right\n"); - strcat(subtext, " clicking duplicates a sprite and places it the cursor.\n"); - strcat(subtext, " When sprites are stacked, only the lowest listed sprite is selected.\n"); - strcat(subtext, " Hovering over multiple sprites and cycling with C allows\n"); - strcat(subtext, " you to change the order that sprites are drawn in the editor.\n"); - strcat(subtext, "Brush: Same as pencil, but draws a larger area at once.\n"); - strcat(subtext, "Select: Selects area of tiles or sprites. Tiles can be copied/\n"); - strcat(subtext, " pasted/deleted in groups. Sprites can be moved in groups\n"); - strcat(subtext, " with ALT + Arrow Keys. Selection can be moved with CTRL + \n"); - strcat(subtext, " Arrow Keys, and resized with SHIFT + Arrow Keys.\n"); - strcat(subtext, "Fill: Fills in left-clicked area with currently selected tile.\n"); + "\n\nSee EDITING for full documentation." + "\n\nThis software is copyright 2018 (c)" + "\nSheridan Rathbun, all rights reserved." + "\n\nSee LICENSE for details.\n"); button = newButton(); strcpy(button->label, "OK"); @@ -1573,6 +1526,109 @@ void buttonAbout(button_t* my) button->focused = 1; } +void buttonEditorToolsHelp(button_t* my) +{ + node_t* node; + node_t* nextnode; + button_t* button; + for ( node = button_l.first; node != NULL; node = nextnode ) + { + nextnode = node->next; + button = (button_t*)node->element; + if ( button->focused ) + { + list_RemoveNode(button->node); + continue; + } + } + subwindow = 1; + if ( newwindow == 16 ) + { + newwindow = 17; + subx1 = xres / 2 - 280; + subx2 = xres / 2 + 280; + suby1 = yres / 2 - 180; + suby2 = yres / 2 + 180; + + button = newButton(); + strcpy(button->label, "OK"); + button->sizex = 9 * 12 + 8; + button->x = xres / 2 - button->sizex - 4; + button->y = suby2 - 24; + button->sizey = 16; + button->action = &buttonCloseSubwindow; + button->visible = 1; + button->focused = 1; + + button = newButton(); + strcpy(button->label, "Next Page"); + button->x = xres / 2 + 4; + button->y = suby2 - 24; + button->sizex = strlen(button->label) * 12 + 8; + button->sizey = 16; + button->action = &buttonEditorToolsHelp; + button->visible = 1; + button->focused = 1; + + button = newButton(); + strcpy(button->label, "X"); + button->x = subx2 - 16; + button->y = suby1; + button->sizex = 16; + button->sizey = 16; + button->action = &buttonCloseSubwindow; + button->visible = 1; + button->focused = 1; + } + else + { + buttonEditorControls(nullptr); + } +} + +void buttonEditorControls(button_t* my) +{ + button_t* button; + + menuVisible = 0; + subwindow = 1; + newwindow = 16; + subx1 = xres / 2 - 250; + subx2 = xres / 2 + 250; + suby1 = yres / 2 - 250; + suby2 = yres / 2 + 250; + + button = newButton(); + strcpy(button->label, "OK"); + button->sizex = 9 * 12 + 8; + button->x = xres / 2 - button->sizex - 4; + button->y = suby2 - 24; + button->sizey = 16; + button->action = &buttonCloseSubwindow; + button->visible = 1; + button->focused = 1; + + button = newButton(); + strcpy(button->label, "Next Page"); + button->x = xres / 2 + 4; + button->y = suby2 - 24; + button->sizex = strlen(button->label) * 12 + 8; + button->sizey = 16; + button->action = &buttonEditorToolsHelp; + button->visible = 1; + button->focused = 1; + + button = newButton(); + strcpy(button->label, "X"); + button->x = subx2 - 16; + button->y = suby1; + button->sizex = 16; + button->sizey = 16; + button->action = &buttonCloseSubwindow; + button->visible = 1; + button->focused = 1; +} + // Subwindows void buttonCloseSubwindow(button_t* my) { diff --git a/src/editor.cpp b/src/editor.cpp index 9a4cc86b6..b0500ef63 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -1705,14 +1705,24 @@ int main(int argc, char** argv) // help menu butAbout = button = newButton(); - strcpy(button->label, "About F1"); + strcpy(button->label, "About F1"); button->x = 168; button->y = 16; - button->sizex = 80; + button->sizex = 160; button->sizey = 16; button->action = &buttonAbout; button->visible = 0; + // controls menu + butEditorControls = button = newButton(); + strcpy(button->label, "Editor Help H"); + button->x = 168; + button->y = 32; + button->sizex = 160; + button->sizey = 16; + button->action = &buttonEditorControls; + button->visible = 0; + if ( loadingmap ) { if ( loadMap(physfsFormatMapName(maptoload).c_str(), &map, map.entities, map.creatures) == -1 ) @@ -1812,7 +1822,7 @@ int main(int argc, char** argv) } else if ( menuVisible == 5 ) { - if ((omousex > 168 + butAbout->sizex || omousex < 152 || omousey > 32 || (omousey < 16 && omousex > 192)) && mousestatus[SDL_BUTTON_LEFT]) + if ((omousex > 168 + butAbout->sizex || omousex < 152 || omousey > 48 || (omousey < 32 && omousex > 192)) && mousestatus[SDL_BUTTON_LEFT]) { menuVisible = 0; menuDisappear = 1; @@ -2413,12 +2423,14 @@ int main(int argc, char** argv) } if ( menuVisible == 5 ) { - drawWindowFancy(152, 16, 168, 32); + drawWindowFancy(152, 16, 168, 48); butAbout->visible = 1; + butEditorControls->visible = 1; } else { butAbout->visible = 0; + butEditorControls->visible = 0; } // subwindows @@ -5492,6 +5504,163 @@ int main(int argc, char** argv) } } } + else if ( newwindow == 16 || newwindow == 17 ) + { + int textColumnLeft = subx1 + 16; + int textColumnRight = (subx2 - subx1) / 2 + 300; + int pady = suby1 + 16; + int spacing = 0; + Uint32 colorHeader = SDL_MapRGB(mainsurface->format, 0, 255, 0); + char helptext[128]; + + if ( newwindow == 16 ) + { + printTextFormattedColor(font8x8_bmp, textColumnLeft, pady + spacing, colorHeader, "Editor File Shortcuts:"); + spacing += 12; + strcpy(helptext, "New Map: CTRL + N"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Open: CTRL + O"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Save: CTRL + S"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Change Load/Save Directory: CTRL + D"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Close Window/Dialogue: CTRL + M"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Delete Text: Backspace or Grave (`)"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + + spacing += 16; + + printTextFormattedColor(font8x8_bmp, textColumnLeft, pady + spacing, colorHeader, "Editor Functions:"); + spacing += 12; + strcpy(helptext, "Open Sprite Window: S"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Open Tile Window: T"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Sprite Properties: F2"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Map Properties: CTRL + M"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Delete Selected Sprite: DEL"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Cycle Stacked Sprites: C"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + + spacing += 16; + + printTextFormattedColor(font8x8_bmp, textColumnLeft, pady + spacing, colorHeader, "Navigation:"); + spacing += 12; + strcpy(helptext, "Move Camera/View: Arrow Keys"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Change Current Wall Layer: SHIFT + Scrollwheel"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Change Current Wall Layer: CTRL + U, CTRL + P"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Toggle First Person Camera: F"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + + spacing += 16; + + printTextFormattedColor(font8x8_bmp, textColumnLeft, pady + spacing, colorHeader, "Tile Palette (Last Used Tiles):"); + spacing += 12; + strcpy(helptext, "Cycle Through Current Tile Palette: Scrollwheel"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Cycle Through All Palettes: CTRL + Scrollwheel"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Choose Specific Tile In Palette: Numpad 0-9"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Choose Specific Tile In Palette: Left Click Tile"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Lock Changes to Current Palette: Numpad *"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Go To Next Palette: Numpad +"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Go To Previous Palette: Numpad -"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, "Clear Tile in Palette: Right Click Tile"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + } + else if ( newwindow == 17 ) + { + printTextFormattedColor(font8x8_bmp, textColumnLeft, pady + spacing, colorHeader, "Editing Tools:"); + spacing += 20; + + printTextFormattedColor(font8x8_bmp, textColumnLeft, pady + spacing, colorHeader, "Pencil:"); + strcpy(helptext, " Draws currently selected tile on current wall layer."); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, " Does not select sprites. Right click sets the selected tile"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, " under the cursor to selected."); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 20; + printTextFormattedColor(font8x8_bmp, textColumnLeft, pady + spacing, colorHeader, "Point:"); + strcpy(helptext, " Selects sprites only. Sprites can be moved or deleted once"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, " placed and selected with this tool. Left click selects, right"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, " clicking duplicates a sprite and places it the cursor."); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, " When sprites are stacked, only the lowest listed sprite is"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, " selected. Hovering over multiple sprites and cycling with C"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, " allows you to change the order that sprites are drawn in"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, " the editor."); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 20; + printTextFormattedColor(font8x8_bmp, textColumnLeft, pady + spacing, colorHeader, "Brush:"); + strcpy(helptext, " Same as pencil, but draws a larger area at once."); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 20; + printTextFormattedColor(font8x8_bmp, textColumnLeft, pady + spacing, colorHeader, "Select:"); + strcpy(helptext, " Selects area of tiles or sprites. Tiles can be copied/"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, " pasted/deleted in groups. Sprites can be moved in groups"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, " with ALT + Arrow Keys. Selection can be moved with CTRL + "); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + strcpy(helptext, " Arrow Keys, and resized with SHIFT + Arrow Keys.\n"); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 20; + printTextFormattedColor(font8x8_bmp, textColumnLeft, pady + spacing, colorHeader, "Fill:"); + strcpy(helptext, " Fills in left-clicked area with currently selected tile."); + printTextFormatted(font8x8_bmp, textColumnLeft, pady + spacing, helptext); + spacing += 12; + } + } if ( keystatus[SDL_SCANCODE_ESCAPE] ) { @@ -5504,6 +5673,10 @@ int main(int argc, char** argv) { buttonCloseSubwindow(NULL); } + if ( newwindow == 16 || newwindow == 17 ) + { + buttonCloseSubwindow(NULL); + } } if ( keystatus[SDL_SCANCODE_RETURN] ) { @@ -5520,6 +5693,14 @@ int main(int argc, char** argv) { //buttonSaveConfirm(NULL); } + if ( newwindow == 16 ) + { + buttonEditorToolsHelp(nullptr); + } + else if ( newwindow == 17 ) + { + buttonCloseSubwindow(nullptr); + } } } else @@ -5948,6 +6129,11 @@ int main(int argc, char** argv) keystatus[SDL_SCANCODE_F1] = 0; buttonAbout(NULL); } + if ( keystatus[SDL_SCANCODE_H] ) + { + keystatus[SDL_SCANCODE_H] = 0; + buttonEditorControls(NULL); + } if ( keystatus[SDL_SCANCODE_1] ) // Switch to Pencil Tool { keystatus[SDL_SCANCODE_1] = 0; diff --git a/src/editor.hpp b/src/editor.hpp index 55c8eb68f..e814d6bf1 100644 --- a/src/editor.hpp +++ b/src/editor.hpp @@ -94,6 +94,7 @@ extern button_t* butAttributes; extern button_t* butClearMap; extern button_t* butHelp; extern button_t* butAbout; +extern button_t* butEditorControls; extern button_t* but3DMode; extern int menuVisible; @@ -187,6 +188,8 @@ void buttonClearMap(button_t* my); void buttonClearMapConfirm(button_t* my); void buttonHelp(button_t* my); void buttonAbout(button_t* my); +void buttonEditorToolsHelp(button_t* my); +void buttonEditorControls(button_t* my); void buttonCloseSubwindow(button_t* my); void buttonSpriteProperties(button_t* my); void buttonSpritePropertiesConfirm(button_t* my);