1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#include "gamesequence/gamesequence.h"
#include "menuui/trainingmenu.h"
#include "graphics/2d.h"
#include "menuui/snazzyui.h"
// global to this file
static int trainingMenuBitmap;
static int trainingMenuMask;
static bitmap* trainingMenuMaskPtr;
static ubyte* mask_data;
static int Training_mask_w, Training_mask_h;
static MENU_REGION region[TRAINING_MENU_MAX_CHOICES];
static int num_training;
static int training_menu_inited=0;
void training_menu_init()
{
char background_img_filename[MAX_FILENAME_LEN];
char background_mask_filename[MAX_FILENAME_LEN];
snazzy_menu_init();
read_menu_tbl(NOX("TRAINING MENU"), background_img_filename, background_mask_filename, region, &num_training);
// load in the background bitmap (filenames are hard-coded temporarily)
trainingMenuBitmap = bm_load(background_img_filename);
if (trainingMenuBitmap < 0) {
Error(LOCATION,"Could not load in %s!",background_img_filename);
}
trainingMenuMask = bm_load(background_mask_filename);
Training_mask_w = -1;
Training_mask_h = -1;
if (trainingMenuMask < 0) {
Error(LOCATION,"Could not load in %s!",background_mask_filename);
}
else {
// get a pointer to bitmap by using bm_lock()
trainingMenuMaskPtr = bm_lock(trainingMenuMask, 8, BMP_AABITMAP);
mask_data = (ubyte*)trainingMenuMaskPtr->data;
bm_get_info(trainingMenuMask, &Training_mask_w, &Training_mask_h);
}
}
void training_menu_close()
{
if (training_menu_inited) {
// done with the bitmap, so unlock it
bm_unlock(trainingMenuMask);
// unload the bitmaps
bm_release(trainingMenuBitmap);
bm_release(trainingMenuMask);
training_menu_inited = 0;
snazzy_menu_close();
}
}
void training_menu_do_frame(float frametime)
{
int training_menu_choice;
if (!training_menu_inited) {
training_menu_init();
training_menu_inited=1;
}
gr_reset_clip();
gr_set_color(0,0,0);
GR_MAYBE_CLEAR_RES(trainingMenuBitmap);
// set the background
if(trainingMenuBitmap != -1){
gr_set_bitmap(trainingMenuBitmap);
gr_bitmap(0,0);
}
int snazzy_action = -1;
training_menu_choice = snazzy_menu_do(mask_data, Training_mask_w, Training_mask_h, num_training, region, &snazzy_action);
if ( snazzy_action != SNAZZY_CLICKED ){
training_menu_choice = -1;
}
switch (training_menu_choice) {
case TRAINING_MENU_TRAINING_MISSIONS_MASK:
break;
case TRAINING_MENU_REPLAY_MISSIONS_MASK:
// TODO: load the mission and start the briefing
break;
case TRAINING_MENU_RETURN_MASK:
case ESC_PRESSED:
gameseq_post_event(GS_EVENT_MAIN_MENU);
break;
case -1:
// nothing selected
break;
default:
Error(LOCATION, "Unknown option %d in training menu screen", training_menu_choice );
break;
} // end switch
gr_flip();
}
|