root/trunk/scm/widget-control.scm

Revision 21 (checked in by kai, 2 years ago)

Initial commit of ShortHike sources and assets.

Line 
1 ;;--------------------------------------------------------------------------------
2 ;;
3 ;; ShortHike, www.shorthike.com
4 ;;
5 ;; Copyright 2002-2006 by Kai Backman, Mistaril Ltd.
6 ;;
7 ;;--------------------------------------------------------------------------------
8
9
10 ; //   const int CONTROL_WIDTH = 38;
11 ; //   const int CONTROL_HEIGHT = 2 * 35 + 3;
12
13 ; //   Rect dstRect = new Rect(0, 0, CONTROL_WIDTH, CONTROL_HEIGHT);
14
15 ; //   // Render background box
16 ; //   doTextureBox(id, "assets/gui/DockBackground.png", dstRect, 8, 8, 8, 8);
17
18 ; //   const int CONTROL_BUTTON_SIZE = 32;
19 ; //   WidgetID layerMenuID = cID(&doControl, 1010);
20 ; //   WidgetID systemMenuID = cID(&doControl, 1020);
21 ; //   Rect buttonRect = new Rect(dstRect.x + 3, dstRect.y + 3, CONTROL_BUTTON_SIZE, CONTROL_BUTTON_SIZE);
22
23 ; //   // System button
24 ; //   if(doButton(cID(&doControl, 200), cFrameTexture("assets/gui/ControlButtons.png", 4, 4), buttonRect, 4)) {
25 ; //     rGUIManager.makeActive(systemMenuID);
26 ; //   }
27 ; //   buttonRect.y += CONTROL_BUTTON_SIZE + 3;
28
29 ; //   // Layer button
30 ; //   if(doButton(cID(&doControl, 10), cFrameTexture("assets/gui/ControlButtons.png", 4, 4), buttonRect)) {
31 ; //     rGUIManager.makeActive(layerMenuID);
32 ; //   }
33 ; //   buttonRect.y += CONTROL_BUTTON_SIZE + 3;
34
35 ; //   // Popup menus
36
37
38 ; //   const char[][] SYSTEM_MENU_ITEMS = [
39 ; //     "Quit"
40 ; //   ]; 
41  
42 ; //   int menuItem = doPopup(systemMenuID, SYSTEM_MENU_ITEMS);
43 ; //   if(menuItem == 0) rMain().quit();
44
45 ; //   Layer iLayer;
46 ; //   if((iLayer = cast(Layer)doPopup(layerMenuID, LAYER_NAMES)) != -1)
47 ; //     setLayer(iLayer);
48
49 ; //   return Screen.STATION;
50
51 (define widget-control
52   (let*
53       ((CONTROL-WIDTH 38)
54        (CONTROL-HEIGHT (+ (* 3 35) 3))
55        (CONTROL-BUTTON-SIZE 32))
56     (lambda ()
57       (let
58           ((dst-rect (rect 0  0  CONTROL-WIDTH  CONTROL-HEIGHT))
59            (button-rect (rect 3 3 CONTROL-BUTTON-SIZE CONTROL-BUTTON-SIZE))
60            (system-menu-id (cid widget-control 1010))
61            (layer-menu-id (cid widget-control 1020))
62            (modder-menu-id (cid widget-control 1030))
63            (item-id -1))
64         ;; Bevel background
65         (do-texture-box (cid widget-control 10)
66                         "assets/gui/DockBackground.png" dst-rect 8 8 8 8)
67
68         ;; System menu button
69         (if (do-button (cid widget-control 20)
70                        "assets/gui/ControlButtons.png" 4 4 button-rect 4)
71             (gui-make-active system-menu-id))
72
73         ;; Layer menu button
74         (set-rect-y! button-rect (+ (rect-y button-rect) CONTROL-BUTTON-SIZE 3))
75         (if (do-button (cid widget-control 30)
76                        "assets/gui/ControlButtons.png" 4 4 button-rect 0)
77             (gui-make-active layer-menu-id))
78
79         ;; Modder menu button
80         (set-rect-y! button-rect (+ (rect-y button-rect) CONTROL-BUTTON-SIZE 3))
81         (if (do-button (cid widget-control 40)
82                        "assets/gui/ControlButtons.png" 4 4 button-rect 8)
83             (gui-make-active modder-menu-id))
84        
85         ;; Do pop up menu, should use case ..
86         (if (not (= (do-popup system-menu-id '("Quit")) -1))
87             (exit))
88         (if (not (= (do-popup layer-menu-id '("Energy" "Thermal" "Life Support")) -1))
89             (write "Layer selected"))
90         (set! item-id (do-popup modder-menu-id
91                                 '("New Prototype"
92                                   "Edit Prototype"
93                                   "Load Prototype"
94                                   "Save Prototype"
95                                   "Save As Prototype"
96                                   "Import SSM mesh"
97                                   "Import OBJ mesh")))
98         ))))
Note: See TracBrowser for help on using the browser.