Esempio n. 1
0
// Control the hud timer by various mouse clicks:
// Shift+click changed mode Countdown / Stopwatch
// For Countdown, mouse wheel up/down decrease/increase start time.
//		Defaul step 5, +ctrl 1, +alt 30
// Left-click start/stop timer
// Mouse wheel click - reset timer.
//
int Hud_Timer::mouse_click(Uint32 flags)
{
	// change countdown start
	if (flags & (ELW_WHEEL_DOWN|ELW_WHEEL_UP))
	{
		int step = 5;
		if (!mode_coundown)
			return 1;
		if (flags & ELW_CTRL)
			step = 1;
		else if (flags & ELW_ALT)
			step = 30;
		if ((flags & ELW_WHEEL_UP)!=0)
			step *= -1;
		set_start(start_value + step);
	}
	// control mode
	else if (flags & ELW_SHIFT)
	{
		toggle_mode();
		do_window_close_sound();
	}
	else
	{
		// reset
		if (flags & ELW_MID_MOUSE)
			reset();
		// start / stop
		else if (flags & ELW_LEFT_MOUSE)
			toggle_running();
		do_click_sound();
	}
	return 1;
}
Esempio n. 2
0
// handle context menu options
//
int Hud_Timer::cm_handler(window_info *win, int option)
{
	switch (option)
	{
		case CMHT_MODE: toggle_mode(); break;
		case CMHT_RUNSTATE: toggle_running(); break;
		case CMHT_SETTIME:
			{
				if (!input)
					input = new INPUT_POPUP;
				else
					close_ipu(input);
				init_ipu(input, win->window_id, 220, -1, 4, 1, 0, set_timer_time);
				input->x = -230;
				input->y = last_base_y_start;
				display_popup_win(input, hud_timer_popup_title_str);
			}
			break;
		case CMHT_RESET: reset(); break;
		case CMHT_HELP:
			{
				const char *desc = get_option_description("view_hud_timer", INI_FILE_VAR);
				if (desc && (strlen(desc) > 0))
					LOG_TO_CONSOLE(c_green1, desc);
			}
			break;
		case CMHT_KEEPSTATE: break;
		default: return 0;
	}
	return 1;
}
Esempio n. 3
0
/*
 * Handling the selection of a memory index
 */
static void process_select_memory_key(int key) {
	int digit = get_digit(key);
	switch(key)	{
			case STOPWATCH_RS: {
				toggle_running();
				StopWatchStatus.select_memory_mode=0;
				StopWatchStatus.rcl_mode=0;
				StopWatchStatus.sigma_display_mode=0;
				break;
			}
			case STOPWATCH_EXIT: {
				StopWatchStatus.select_memory_mode=0;
				StopWatchStatus.rcl_mode=0;
				StopWatchStatus.sigma_display_mode=0;
				break;
			}
			case STOPWATCH_CLEAR: {
				if(StopWatchMemoryFirstDigit<0) {
					StopWatchStatus.select_memory_mode=0;
					StopWatchStatus.rcl_mode=0;
					StopWatchStatus.sigma_display_mode=0;
				} else {
					StopWatchMemoryFirstDigit=-1;
				}
				break;
			   }
			case STOPWATCH_STORE: {
				if(StopWatchMemoryFirstDigit>=0) {
					end_memory_selection(StopWatchMemoryFirstDigit);
				}
				break;
			}
			default: {
				if (digit >= 0) {
					int max_registers=global_regs();
					// Digits
					if(StopWatchMemoryFirstDigit<0) {
						if(digit<=max_registers/10) {
							StopWatchMemoryFirstDigit=digit;
						} else if(max_registers<=10 && digit<max_registers) {
							end_memory_selection(digit);
						}
					} else {
					int index=StopWatchMemoryFirstDigit*10+digit;
					if(index<max_registers) {
						end_memory_selection(index);
					}
					}
				}
				break;
			  }
	}
}
Esempio n. 4
0
/*
 * Handling keys.As we need to be a 'special mode', we have to do it ourselves
 * We cannot reuse the normal main loop code
 */
static void process_stopwatch_key(int key) {
	int max_registers=global_regs();
	switch(key)	{
			case STOPWATCH_RS: {
				toggle_running();
				break;
			}
			case STOPWATCH_EXIT: {
				KeyCallback=(int(*)(int))NULL;
				break;
			}
			case STOPWATCH_CLEAR: {
				if(StopWatchStatus.running)	{
					if(TotalFirstTicker==0) {
						TotalFirstTicker=FirstTicker;
					}
					FirstTicker=getTicker();
				} else {
					TotalFirstTicker=0;
					FirstTicker=0;
				}
				StopWatch=0;
				break;
			   }
			case STOPWATCH_EEX: {
				StopWatchStatus.display_tenths=!StopWatchStatus.display_tenths;
				break;
				}
			case STOPWATCH_STORE: {
				store_stopwatch_in_memory();
				break;
				}
			case STOPWATCH_STORE_ROUND: {
				store_stopwatch_in_memory();
				if(TotalFirstTicker==0) {
					TotalFirstTicker=FirstTicker;
				}
				FirstTicker=getTicker();
				break;
				}
			case STOPWATCH_SIGMA_PLUS_STORE_ROUND: {
				store_stopwatch_in_memory();
				stopwatch_sigma_plus();
				break;
			}
			case STOPWATCH_SIGMA_PLUS: {
				stopwatch_sigma_plus();
				break;
			}
			case STOPWATCH_UP: {
				if(StopWatchMemory<max_registers-1) {
					StopWatchMemory++;
				}
				break;
				}
			case STOPWATCH_DOWN: {
				if(StopWatchMemory>0) {
					StopWatchMemory--;
				}
				break;
				}
			case STOPWATCH_SHOW_MEMORY: {
				StopWatchStatus.show_memory=!StopWatchStatus.show_memory;
				break;
				}
			case STOPWATCH_RCL: {
				StopWatchStatus.rcl_mode=max_registers>0;
				StopWatchStatus.sigma_display_mode=0;
				StopWatchMemoryFirstDigit=-1;
				break;
				}
			default: {
				if (get_digit(key) >= 0) {
					//Digits
					StopWatchStatus.select_memory_mode=1;
					StopWatchMemoryFirstDigit=-1;
					StopWatchStatus.show_memory=1;
					process_select_memory_key(key);
				}
				break;
			  }
			}
}