#include "common.h"
// === CONSTANTS ===
+#define COLOURPAIR_DEFAULT 0
#define COLOURPAIR_CANTBUY 1
#define COLOURPAIR_SELECTED 2
// Enter curses mode
initscr();
start_color();
- init_pair(COLOURPAIR_CANTBUY, COLOR_BLACK, COLOR_BLACK); // Not avaliable
- init_pair(COLOURPAIR_SELECTED, COLOR_GREEN, COLOR_BLACK); // Selected
+ use_default_colors();
+ init_pair(COLOURPAIR_DEFAULT, -1, -1); // Not avaliable
+ init_pair(COLOURPAIR_CANTBUY, COLOR_BLACK, -1); // Not avaliable
+ init_pair(COLOURPAIR_SELECTED, COLOR_GREEN, -1); // Selected
cbreak(); noecho();
// Get max index
return ret;
}
+#define COKE_LABEL "Coke Machine"
+#define NCOKESLOTS 7 // slots 0 -- 6
+#define EPS_LABEL "Electronic Payment System"
+
/**
* \brief Show item \a Index at (\a Col, \a Row)
* \return Dispense index of item
switch(giUIMode)
{
// Standard UI
- // - This assumes that
case UI_MODE_STANDARD:
// Bounds check
// Index = -1, request limit
if( Index == 0 )
{
price = 0;
- name = "Coke Machine";
+ name = COKE_LABEL;
Index = -1; // -1 indicates a label
break;
}
Index --;
// Drinks 0 - 6
- if( Index <= 6 )
+ if( Index < NCOKESLOTS )
{
name = gaItems[Index].Desc;
price = gaItems[Index].Price;
status = gaItems[Index].Status;
break;
}
- Index -= 7;
+ Index -= NCOKESLOTS;
// EPS label
if( Index == 0 )
{
price = 0;
- name = "Electronic Payment System";
+ name = EPS_LABEL;
Index = -1; // -1 indicates a label
break;
}
price = gaItems[Index].Price;
status = gaItems[Index].Status;
break;
+ case UI_MODE_BASIC:
+ case UI_MODE_DRINKSONLY:
+ case UI_MODE_ALL:
default:
return -1;
}
}
// If the item isn't availiable for sale, return -1 (so it's skipped)
- if( status || (price > giUserBalance && gbDisallowSelectWithoutBalance) )
- Index = -1;
+ if( status > 0 || (price > giUserBalance && gbDisallowSelectWithoutBalance) )
+ Index = -2;
return Index;
}