]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Highlight the selected cell in the picker
authorterencehill <piuntn@gmail.com>
Sun, 3 May 2015 11:38:12 +0000 (13:38 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 3 May 2015 11:38:12 +0000 (13:38 +0200)
qcsrc/menu/xonotic/charmap.qc
qcsrc/menu/xonotic/crosshairpicker.qc
qcsrc/menu/xonotic/picker.qc

index eb83ff846de56c4b241f706f0dfbd1c02fbede8d..48e72b7bdedb588c0886795a774ee4ef4cfbdaf0 100644 (file)
@@ -10,7 +10,7 @@ CLASS(XonoticCharmap) EXTENDS(XonoticPicker)
        ATTRIB(XonoticCharmap, rows, float, 10)
        ATTRIB(XonoticCharmap, columns, float, 14)
 
-       METHOD(XonoticCharmap, cellSelect, void(entity))
+       METHOD(XonoticCharmap, cellSelect, void(entity, vector))
        METHOD(XonoticCharmap, cellIsValid, bool(entity, vector))
        METHOD(XonoticCharmap, cellDraw, void(entity, vector, vector, float))
        METHOD(XonoticCharmap, charOffset, vector)
@@ -92,9 +92,9 @@ float XonoticCharmap_keyDown(entity me, float key, float ascii, float shift)
        return me.inputBox.keyDown(me.inputBox, key, ascii, shift);
 }
 
-void XonoticCharmap_cellSelect(entity me)
+void XonoticCharmap_cellSelect(entity me, vector cell)
 {
-       string character = charmap_cellToChar(me, me.focusedCell);
+       string character = charmap_cellToChar(me, cell);
        if(character != "")
                me.inputBox.enterText(me.inputBox, character);
 }
index f79cea51b4ae73c11cf42b603d009a40338c10e9..168ab9cf8d1f139fdc638d2497f04303a9e74fb6 100644 (file)
@@ -5,7 +5,7 @@ CLASS(XonoticCrosshairPicker) EXTENDS(XonoticPicker)
        ATTRIB(XonoticCrosshairPicker, rows, float, 3)
        ATTRIB(XonoticCrosshairPicker, columns, float, 12)
 
-       METHOD(XonoticCrosshairPicker, cellSelect, void(entity))
+       METHOD(XonoticCrosshairPicker, cellSelect, void(entity, vector))
        METHOD(XonoticCrosshairPicker, cellIsValid, bool(entity, vector))
        METHOD(XonoticCrosshairPicker, cellDraw, void(entity, vector, vector, float))
 ENDCLASS(XonoticCrosshairPicker)
@@ -22,6 +22,13 @@ string crosshairpicker_cellToCrosshair(entity me, vector cell)
                return ftos(crosshair);
        else
                return "";
+
+vector crosshairpicker_crosshairToCell(entity me, string crosshair_str)
+{
+       float crosshair = stof(crosshair_str) - 31;
+       if(crosshair - floor(crosshair) > 0)
+               return '-1 -1 0';
+       return mod(crosshair, me.columns) * eX + floor(crosshair / me.columns) * eY;
 }
 
 entity makeXonoticCrosshairPicker()
@@ -35,11 +42,13 @@ entity makeXonoticCrosshairPicker()
 void XonoticCrosshairPicker_configureXonoticCrosshairPicker(entity me)
 {
        me.configureXonoticPicker(me);
+       SUPER(XonoticCrosshairPicker).cellSelect(me, crosshairpicker_crosshairToCell(me, cvar_string("crosshair")));
 }
 
-void XonoticCrosshairPicker_cellSelect(entity me)
+void XonoticCrosshairPicker_cellSelect(entity me, vector cell)
 {
        cvar_set("crosshair", crosshairpicker_cellToCrosshair(me, me.focusedCell));
+       SUPER(XonoticCrosshairPicker).cellSelect(me, me.focusedCell);
 }
 
 bool XonoticCrosshairPicker_cellIsValid(entity me, vector cell)
index b03ddecd0c2bb6ea4e7550bb6dd32d7b41b2f11a..86eb7dc90cb73bebbc7b699e0b521748671855e0 100644 (file)
@@ -16,10 +16,11 @@ CLASS(XonoticPicker) EXTENDS(Item)
        ATTRIB(XonoticPicker, columns, float, 2)
 
        METHOD(XonoticPicker, moveFocus, void(entity, vector, vector))
-       METHOD(XonoticPicker, cellSelect, void(entity))
+       METHOD(XonoticPicker, cellSelect, void(entity, vector))
        METHOD(XonoticPicker, cellDraw, void(entity, vector, vector, float))
        METHOD(XonoticPicker, cellIsValid, bool(entity, vector))
        ATTRIB(XonoticPicker, realCellSize, vector, '0 0 0')
+       ATTRIB(XonoticPicker, selectedCell, vector, '-1 -1 0')
        ATTRIB(XonoticPicker, focusedCell, vector, '-1 -1 0')
        ATTRIB(XonoticPicker, focusedCellTime, float, 0)
        ATTRIB(XonoticPicker, pressedCell, vector, '-1 -1 0')
@@ -87,7 +88,7 @@ float XonoticPicker_mouseRelease(entity me, vector coords)
        me.mouseMove(me, coords);
 
        if(me.focusedCell == me.pressedCell)
-               me.cellSelect(me);
+               me.cellSelect(me, me.focusedCell);
 
        me.pressed = 0;
        return 1;
@@ -126,7 +127,7 @@ float XonoticPicker_keyDown(entity me, float key, float ascii, float shift)
                case K_KP_ENTER:
                case K_INS:
                case K_KP_INS:
-                       me.cellSelect(me);
+                       me.cellSelect(me, me.focusedCell);
                        return 1;
        }
        return 0;
@@ -142,8 +143,9 @@ void XonoticPicker_moveFocus(entity me, vector initialCell, vector step)
                        me.moveFocus(me, initialCell, step);
 }
 
-void XonoticPicker_cellSelect(entity me)
+void XonoticPicker_cellSelect(entity me, vector cell)
 {
+       me.selectedCell = cell;
 }
 
 bool XonoticPicker_cellIsValid(entity me, vector cell)
@@ -179,7 +181,9 @@ void XonoticPicker_draw(entity me)
 
                        cellPos_x = mod(cell.x, me.columns) / me.columns;
 
-                       if(cell == me.focusedCell && me.focused)
+                       if(cell == me.selectedCell)
+                               draw_Fill(cellPos, me.realCellSize, SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
+                       else if(cell == me.focusedCell && me.focused)
                        {
                                if(!me.pressed || me.focusedCell == me.pressedCell)
                                        draw_Fill(cellPos, me.realCellSize, SKINCOLOR_LISTBOX_FOCUSED, getHighlightAlpha(SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED, me.focusedCellTime));