rnd-20030607-1-src
authorHolger Schemel <info@artsoft.org>
Fri, 6 Jun 2003 23:21:23 +0000 (01:21 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:42:00 +0000 (10:42 +0200)
src/conftime.h
src/editor.c
src/events.c
src/screens.c
src/screens.h

index 4ebbb3697a1c7e68ea1e8f1cb752542f440cec5a..071efa6cd5c59ea549e0c55cc46cd5b734e8339a 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2003-06-06 02:25]"
+#define COMPILE_DATE_STRING "[2003-06-07 01:19]"
index 29b34116a901fb4e9ef2630384883061d3013e34..778232e23fc507e9287a4df15b72247fca34ca05 100644 (file)
@@ -3922,7 +3922,7 @@ static boolean PrintInfoText(char *text, int font_nr, int screen_line)
 {
   int font_height = getFontHeight(font_nr);
   int pad_x = ED_SETTINGS_XPOS(0);
-  int pad_y = ED_SETTINGS_YPOS(0);
+  int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
   int sx = SX + pad_x;
   int sy = SY + pad_y;
   int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
@@ -4076,12 +4076,18 @@ static void DrawPropertiesTabulatorGadgets()
   int gd_y = gd->y + gd_gi->height - 1;
   Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y);
   int id_first = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
+#if 1
+  int id_last  = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
+#else
   int id_last  = ED_TEXTBUTTON_ID_PROPERTIES_INFO;
+#endif
   int i;
 
+#if 0
   /* draw additional "configure" tabulator for configurable elements */
   if (checkPropertiesConfig())
     id_last = ED_TEXTBUTTON_ID_PROPERTIES_CONFIG;
+#endif
 
   /* draw additional "advanced" tabulator for custom elements */
   if (IS_CUSTOM_ELEMENT(properties_element))
@@ -4162,7 +4168,7 @@ static void DrawPropertiesInfo()
   int font1_width = getFontWidth(font1_nr);
   int font2_height = getFontHeight(font2_nr);
   int pad_x = ED_SETTINGS_XPOS(0);
-  int pad_y = ED_SETTINGS_YPOS(0);
+  int pad_y = ED_SETTINGS_YPOS(0) + ED_BORDER_SIZE;
   int screen_line = 0;
   int i, x, y;
 
@@ -4303,6 +4309,13 @@ static void DrawPropertiesConfig()
 {
   int i;
 
+  if (!checkPropertiesConfig())
+  {
+    PrintInfoText("No configuration options available.", FONT_TEXT_1, 0);
+
+    return;
+  }
+
   /* check if there are elements where a score can be chosen for */
   for (i=0; elements_with_counter[i].element != -1; i++)
   {
@@ -4401,9 +4414,11 @@ static void DrawPropertiesWindow()
       !IS_CUSTOM_ELEMENT(properties_element))
     edit_mode_properties = ED_MODE_PROPERTIES_CONFIG;
 
+#if 0
   if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG &&
       !checkPropertiesConfig())
     edit_mode_properties = ED_MODE_PROPERTIES_INFO;
+#endif
 
   if (IS_CUSTOM_ELEMENT(properties_element))
     CopyCustomElementPropertiesToEditor(properties_element);
index 2ba138ffd67661107ee06d30444a21ceb36f20b3..619a7f13495fdc76c984724e718cd430d4ba3544 100644 (file)
@@ -626,16 +626,16 @@ void HandleKey(Key key, int key_status)
 
         case KSYM_Page_Up:
           if (game_status == GAME_MODE_LEVELS)
-            HandleChooseLevel(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
+            HandleChooseLevel(0,0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK);
          else if (game_status == GAME_MODE_SETUP)
-           HandleSetupScreen(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
+           HandleSetupScreen(0,0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK);
          break;
 
         case KSYM_Page_Down:
           if (game_status == GAME_MODE_LEVELS)
-            HandleChooseLevel(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
+            HandleChooseLevel(0,0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK);
          else if (game_status == GAME_MODE_SETUP)
-           HandleSetupScreen(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
+           HandleSetupScreen(0,0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK);
          break;
 
 #ifdef DEBUG
@@ -663,11 +663,11 @@ void HandleKey(Key key, int key_status)
          break;
 
         case KSYM_Page_Up:
-         HandleHallOfFame(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
+         HandleHallOfFame(0,0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK);
          break;
 
         case KSYM_Page_Down:
-         HandleHallOfFame(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
+         HandleHallOfFame(0,0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK);
          break;
 
        default:
index 1b8d27b414011d5c3db6cb14c731fbe9349c5a2a..1012b6ede9ad692b7bdaf6ed9d1a25d3f71c793a 100644 (file)
@@ -301,7 +301,7 @@ static void gotoTopLevelDir()
       if (num_leveldirs <= MAX_MENU_ENTRIES_ON_SCREEN)
        num_page_entries = num_leveldirs;
       else
-       num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1;
+       num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN;
 
       cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
       cl_cursor = leveldir_pos - cl_first;
@@ -1188,7 +1188,7 @@ static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti)
   int items_max, items_visible, item_position;
 
   items_max = numTreeInfoInGroup(ti);
-  items_visible = MAX_MENU_ENTRIES_ON_SCREEN - 1;
+  items_visible = MAX_MENU_ENTRIES_ON_SCREEN;
   item_position = first_entry;
 
   if (item_position > items_max - items_visible)
@@ -1204,10 +1204,9 @@ static void drawChooseTreeList(int first_entry, int num_page_entries,
   int i;
   char buffer[SCR_FIELDX * 2];
   int max_buffer_len = (SCR_FIELDX - 2) * 2;
-  int num_entries = numTreeInfoInGroup(ti);
   char *title_string = NULL;
   int xoffset_setup = 16;
-  int yoffset_setup = 0;
+  int yoffset_setup = 16;
   int xoffset = (ti->type == TREE_TYPE_LEVEL_DIR ? 0 : xoffset_setup);
   int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ? 0 : yoffset_setup);
   int last_game_status = game_status;  /* save current game status */
@@ -1248,24 +1247,6 @@ static void drawChooseTreeList(int first_entry, int num_page_entries,
       initCursor(i, IMG_MENU_BUTTON);
   }
 
-  if (first_entry > 0)
-  {
-    int ypos = 1;
-
-    DrawBackground(mSX, mSY + ypos * TILEY, TILEX, TILEY);
-    DrawGraphicThruMaskExt(drawto, mSX, mSY + ypos * TILEY,
-                          IMG_MENU_BUTTON_UP, 0);
-  }
-
-  if (first_entry + num_page_entries < num_entries)
-  {
-    int ypos = MAX_MENU_ENTRIES_ON_SCREEN + 1;
-
-    DrawBackground(mSX, mSY + ypos * TILEY, TILEX, TILEY);
-    DrawGraphicThruMaskExt(drawto, mSX, mSY + ypos * TILEY,
-                          IMG_MENU_BUTTON_DOWN, 0);
-  }
-
   game_status = last_game_status;      /* restore current game status */
 }
 
@@ -1301,7 +1282,6 @@ static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
                             TreeInfo **ti_ptr)
 {
-  static unsigned long choose_delay = 0;
   TreeInfo *ti = *ti_ptr;
   int x = 0;
   int y = ti->cl_cursor;
@@ -1312,7 +1292,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
   if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN)
     num_page_entries = num_entries;
   else
-    num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1;
+    num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN;
 
   if (button == MB_MENU_INITIALIZE)
   {
@@ -1361,52 +1341,56 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
     x = (mx - mSX) / 32;
     y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
   }
-  else if (dx || dy)   /* keyboard input */
+  else if (dx || dy)   /* keyboard or scrollbar/scrollbutton input */
   {
-    if (dy)
-      y = ti->cl_cursor + dy;
+    /* move cursor instead of scrolling when already at start/end of list */
+    if (dy == -1 * SCROLL_LINE && ti->cl_first == 0)
+      dy = -1;
+    else if (dy == +1 * SCROLL_LINE &&
+            ti->cl_first + num_page_entries == num_entries)
+      dy = 1;
 
-    if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
+    /* handle scrolling screen one line or page */
+    if (ti->cl_cursor + dy < 0 ||
+       ti->cl_cursor + dy > num_page_entries - 1)
     {
-      dy = SIGN(dy);
-      step = num_page_entries - 1;
-      y = (dy < 0 ? -1 : num_page_entries);
-    }
-  }
+      if (ABS(dy) == SCROLL_PAGE)
+       step = num_page_entries - 1;
 
-  if (x == 0 && y == -1)
-  {
-    if (ti->cl_first > 0 &&
-       (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
-    {
-      ti->cl_first -= step;
-      if (ti->cl_first < 0)
-       ti->cl_first = 0;
+      if (dy < 0 && ti->cl_first > 0)
+      {
+       /* scroll page/line up */
 
-      drawChooseTreeList(ti->cl_first, num_page_entries, ti);
-      drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
-      drawCursor(ti->cl_cursor, FC_RED);
-      AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
-                               ti->cl_first, ti);
-      return;
-    }
-  }
-  else if (x == 0 && y > num_page_entries - 1)
-  {
-    if (ti->cl_first + num_page_entries < num_entries &&
-       (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
-    {
-      ti->cl_first += step;
-      if (ti->cl_first + num_page_entries > num_entries)
-       ti->cl_first = MAX(0, num_entries - num_page_entries);
+       ti->cl_first -= step;
+       if (ti->cl_first < 0)
+         ti->cl_first = 0;
+
+       drawChooseTreeList(ti->cl_first, num_page_entries, ti);
+       drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
+       drawCursor(ti->cl_cursor, FC_RED);
+       AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
+                                 ti->cl_first, ti);
+      }
+      else if (dy > 0 && ti->cl_first + num_page_entries < num_entries)
+      {
+       /* scroll page/line down */
+
+       ti->cl_first += step;
+       if (ti->cl_first + num_page_entries > num_entries)
+         ti->cl_first = MAX(0, num_entries - num_page_entries);
+
+       drawChooseTreeList(ti->cl_first, num_page_entries, ti);
+       drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
+       drawCursor(ti->cl_cursor, FC_RED);
+       AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
+                                 ti->cl_first, ti);
+      }
 
-      drawChooseTreeList(ti->cl_first, num_page_entries, ti);
-      drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
-      drawCursor(ti->cl_cursor, FC_RED);
-      AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
-                               ti->cl_first, ti);
       return;
     }
+
+    /* handle moving cursor one line */
+    y = ti->cl_cursor + dy;
   }
 
   if (dx == 1)
@@ -1579,7 +1563,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
     return;
   }
 
-  if (ABS(dy) == SCR_FIELDY)   /* handle KSYM_Page_Up, KSYM_Page_Down */
+  if (ABS(dy) == SCROLL_PAGE)          /* handle scrolling one page */
     step = MAX_MENU_ENTRIES_ON_SCREEN - 1;
 
   if (dy < 0)
@@ -1909,9 +1893,11 @@ static void drawSetupValue(int pos)
     if (strlen(value_string) > max_value_len)
       value_string[max_value_len] = '\0';
   }
-  else if (setup_info[pos].type & TYPE_BOOLEAN_STYLE &&
-          !*(boolean *)(setup_info[pos].value))
-    font_nr = FONT_OPTION_OFF;
+  else if (setup_info[pos].type & TYPE_BOOLEAN_STYLE)
+  {
+    font_nr = (*(boolean *)(setup_info[pos].value) ? FONT_OPTION_ON :
+              FONT_OPTION_OFF);
+  }
 
   DrawText(mSX + xpos * 32, mSY + ypos * 32,
           (xpos == 3 ? "              " : "   "), font_nr);
@@ -2749,17 +2735,20 @@ void HandleGameActions()
 /* ---------- new screen button stuff -------------------------------------- */
 
 /* graphic position and size values for buttons and scrollbars */
-#define SC_SCROLLBUTTON_XSIZE          32
-#define SC_SCROLLBUTTON_YSIZE          32
+#define SC_SCROLLBUTTON_XSIZE          TILEX
+#define SC_SCROLLBUTTON_YSIZE          TILEY
 
+#define SC_SCROLL_VERTICAL_XSIZE       SC_SCROLLBUTTON_XSIZE
+#define SC_SCROLL_VERTICAL_YSIZE       ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \
+                                        SC_SCROLLBUTTON_YSIZE)
 #define SC_SCROLL_UP_XPOS              (SXSIZE - SC_SCROLLBUTTON_XSIZE)
-#define SC_SCROLL_UP_YPOS              SC_SCROLLBUTTON_YSIZE
-#define SC_SCROLL_DOWN_XPOS            SC_SCROLL_UP_XPOS
-#define SC_SCROLL_DOWN_YPOS            (SYSIZE - SC_SCROLLBUTTON_YSIZE)
+#define SC_SCROLL_UP_YPOS              (2 * SC_SCROLLBUTTON_YSIZE)
 #define SC_SCROLL_VERTICAL_XPOS                SC_SCROLL_UP_XPOS
-#define SC_SCROLL_VERTICAL_YPOS          (SC_SCROLL_UP_YPOS + SC_SCROLLBUTTON_YSIZE)
-#define SC_SCROLL_VERTICAL_XSIZE       SC_SCROLLBUTTON_XSIZE
-#define SC_SCROLL_VERTICAL_YSIZE       (SYSIZE - 3 * SC_SCROLLBUTTON_YSIZE)
+#define SC_SCROLL_VERTICAL_YPOS                (SC_SCROLL_UP_YPOS + \
+                                        SC_SCROLLBUTTON_YSIZE)
+#define SC_SCROLL_DOWN_XPOS            SC_SCROLL_UP_XPOS
+#define SC_SCROLL_DOWN_YPOS            (SC_SCROLL_VERTICAL_YPOS + \
+                                        SC_SCROLL_VERTICAL_YSIZE)
 
 #define SC_BORDER_SIZE                 14
 
@@ -2882,7 +2871,7 @@ static void CreateScreenScrollbars()
     struct GadgetInfo *gi;
     int items_max, items_visible, item_position;
     unsigned long event_mask;
-    int num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1;
+    int num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN;
     int id = scrollbar_info[i].gadget_id;
 
     items_max = num_page_entries;
@@ -3012,16 +3001,16 @@ static void HandleScreenGadgets(struct GadgetInfo *gi)
   {
     case SCREEN_CTRL_ID_SCROLL_UP:
       if (game_status == GAME_MODE_LEVELS)
-       HandleChooseLevel(mSX,mSY + 32, 0,0, MB_MENU_MARK);
+       HandleChooseLevel(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
       else if (game_status == GAME_MODE_SETUP)
-       HandleSetupScreen(mSX,mSY + 32, 0,0, MB_MENU_MARK);
+       HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK);
       break;
 
     case SCREEN_CTRL_ID_SCROLL_DOWN:
       if (game_status == GAME_MODE_LEVELS)
-       HandleChooseLevel(mSX,mSY + SYSIZE - 32, 0,0, MB_MENU_MARK);
+       HandleChooseLevel(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
       else if (game_status == GAME_MODE_SETUP)
-       HandleSetupScreen(mSX,mSY + SYSIZE - 32, 0,0, MB_MENU_MARK);
+       HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK);
       break;
 
     case SCREEN_CTRL_ID_SCROLL_VERTICAL:
index c4485691a55cf13c8063c8a3c9796530db7448d2..f4b704b462553ec3b090f6639c9a918d8ee524c9 100644 (file)
 
 #include "main.h"
 
+/* (randomly chosen) values for HandleChooseTree() */
+#define SCROLL_LINE    (1 * SCR_FIELDY)
+#define SCROLL_PAGE    (2 * SCR_FIELDY)
+
+
 void DrawHeadline(void);
 
 void DrawMainMenu(void);