Beispiel #1
0
/*
 * Save the currently loaded configuration.
 */
void uae_save_config (void)
{
    FILE *f;
    char tmp[257];

    /* Back up the old file.  */
    strcpy (tmp, optionsfile);
    strcat (tmp, "~");
    write_log ("Backing-up config file '%s' to '%s'\n", optionsfile, tmp);
    rename (optionsfile, tmp);

    write_log ("Writing new config file '%s'\n", optionsfile);
    f = fopen (optionsfile, "w");
    if (f == NULL) {
	gui_message ("Error saving configuration file.!\n"); // FIXME - better error msg.
	return;
    }

    // FIXME  - either fix this nonsense, or only allow config to be saved when emulator is stopped.
    if (uae_get_state () == UAE_STATE_STOPPED)
	save_options (f, &changed_prefs, 0);
    else
	save_options (f, &currprefs, 0);

    fclose (f);
}
Beispiel #2
0
void load_options()
{
    std::ifstream fin;
    fin.open("data/options.txt");
    if(!fin.is_open()) {
        fin.close();
        save_options();
        fin.open("data/options.txt");
        if(!fin.is_open()) {
            DebugLog() << "Could neither read nor create ./data/options.txt\n";
            return;
        }
    }

    std::string sLine;
    while(!fin.eof()) {
        getline(fin, sLine);

        if(sLine != "" && sLine[0] != '#' && std::count(sLine.begin(), sLine.end(), ' ') == 1) {
            int iPos = sLine.find(' ');
            OPTIONS[sLine.substr(0, iPos)].setValue(sLine.substr(iPos+1, sLine.length()));
        }
    }

    fin.close();

    trigdist = OPTIONS["CIRCLEDIST"]; // cache to global due to heavy usage.
    use_tiles = OPTIONS["USE_TILES"]; // cache to global due to heavy usage.
}
Beispiel #3
0
int Main::run() {
	if(!init()) return 1;

	frame_delay = 1000 / FRAMES_PER_SECOND;
	frame = 0;

	load_options();

	fps_counter_timer->start();

	Menu * menu;
	menu = new Menu();

	running = true;
	menu->run();

	delete menu;

	save_options();

	clean_up();

#ifdef _DEBUG
#ifdef WIN32
	_CrtDumpMemoryLeaks();
#endif
#endif
	return 0;
}
Beispiel #4
0
std::unordered_map<std::string, cOpt> worldfactory::get_world_options(std::string path)
{
    auto retoptions = get_default_world_options();
    std::ifstream fin;

    fin.open(path.c_str());

    if (!fin.is_open()) {
        fin.close();
        save_options();

        fin.open(path.c_str());
        if (!fin.is_open()) {
            fin.close();
            DebugLog( D_ERROR, DC_ALL ) << "Could neither read nor create world options file";
            return retoptions;
        }
    }
    std::string sLine;

    while (!fin.eof()) {
        getline(fin, sLine);

        if (sLine != "" && sLine[0] != '#' && std::count(sLine.begin(), sLine.end(), ' ') == 1) {
            int ipos = sLine.find(' ');
            // make sure that the option being loaded is part of the world_default page in OPTIONS
            if(OPTIONS[sLine.substr(0, ipos)].getPage() == "world_default") {
                retoptions[sLine.substr(0, ipos)].setValue(sLine.substr(ipos + 1, sLine.length()));
            }
        }
    }
    fin.close();

    return retoptions;
}
Beispiel #5
0
static gboolean
prepare_screenshot_timeout (gpointer data)
{
  prepare_screenshot ();
  save_options ();

  return FALSE;
}
Beispiel #6
0
void activate_option(int option)
{
	u8 *temp;
	int length;
	switch(option)
	{
		case CONSOLE_NICKNAME_OFFSET:
			temp=(u8*)memalign(32, 128);
			memset(temp,0,sizeof temp);//SYSCONF_GetNickName(temp);
			ClearScreen();
			printf("\n\nEnter new name for your console: %s",temp);
			length=type_string_wiimote((char*)temp, 10);
//			length=type_string_usb_kbd(temp, 10);
			if(length>0)
			{
				SYSCONF_SetNickName(temp, length);
				free(temp);
			}
			break;

		case PARENTAL_PASSWORD_OFFSET:
/*			temp=(u8*)memalign(32, 128);
			SYSCONF_GetParentalPassword(temp);
			length=type_string_usb_kbd(temp, 4);
			if(length!=4)
			{
				for(i=length;i<4;i++)
					temp[i]='\0';
			}
			SYSCONF_SetParentalPassword(temp, 4);
			free(temp);*/
			break;

		case PARENTAL_ANSWER_OFFSET:
/*			temp=(u8*)memalign(32, 128);
			SYSCONF_GetParentalAnswer(temp);
			type_string_usb_kbd(temp, 32);
			if(length!=32)
			{
				for(i=length;i<32;i++)
					temp[i]='\0';
			}
			SYSCONF_SetParentalAnswer(temp);
			free(temp);*/
			break;

		case SAVE_OFFSET:
			save_options();
			break;

		case EXIT_OFFSET:
			quit_options();
			break;

		default:
			break;
	}
}
Beispiel #7
0
Datei: Mixer.C Projekt: imv/non
Mixer::~Mixer ( )
{
    DMESSAGE( "Destroying mixer" );

    save_options();

    /* FIXME: teardown */
    mixer_strips->clear();
}
//{{{
void options_menu(void)
{
	int choice;
	int old_value, new_value;
	int change_made = 0;
	
	setTabStops(options_menu_tabs);
	UI_Menu_Set_Persist(1);
	while(1) {
#ifdef OPTIONS_SUBMENUS
		choice = UI_Menu_Pick(options_rect, count_options()+OPTIONS_SUBMENUS,
		                      &cb_options_menu);
		if(choice>=0 && choice<OPTIONS_SUBMENUS) {
			pick_submenu(choice);
			change_made = 1;
			continue;
		} else {
			choice -= OPTIONS_SUBMENUS;
		}
#else
		choice = UI_Menu_Pick(options_rect, count_options(), &cb_options_menu);
#endif
		
		if(choice<0)
			break;
		old_value = get_option(options[choice].key);
		new_value = (old_value+1) % count_choices(options[choice].choices);
		set_option(options[choice].key, new_value);
		change_made = 1;
		
#ifdef IS_CALCULATOR
		if(options[choice].key == OPTION_GRAYSCALE)
		{
			if(get_option(OPTION_GRAYSCALE) == OPTION_GRAY_ON)
				GrayOnThrow();
			else
				GrayOff();
			if(w->level) // Only if game is started
				full_redraw();
		}
#endif
#ifdef PALMOS
		if(options[choice].key == OPTION_INVERSE)
			init_colors();
#endif
#ifdef REALCOMPUTER
		if(options[choice].key == OPTION_COLOR)
			init_colors();
#endif
	}
	UI_Menu_Set_Persist(0);
	
	if(change_made)
		save_options();
}
Beispiel #9
0
static void save_options_as(void)
{
	char *newname;

	if ((newname = locate(optname, L_SAVECFG)) != NULL)
	{
		free(optname);
		optname = newname;
		save_options();
	}
}
Beispiel #10
0
void addPickupRule(std::string sRule)
{
    vAutoPickupRules[2].push_back(cPickupRules(sRule, true, false));
    merge_vector();
    createPickupRules();

    if (!OPTIONS["AUTO_PICKUP"] &&
        query_yn(_("Autopickup is not enabled in the options. Enable it now?")) ) {
        OPTIONS["AUTO_PICKUP"].setNext();
        save_options(true);
    }
}
Beispiel #11
0
static void save_settings (void)
{
    FILE *f;
    tui_backup_optionsfile ();
    f = fopen (optionsfile, "w");
    if (f == NULL) {
	write_log ("Error saving options file!\n");
	return;
    }
    save_options (f, &currprefs, 0);
    fclose (f);
}
Beispiel #12
0
void MainWindow::on_option_clicked()
{
	OptionDialog dlg;
	if (dlg.exec())
	{
		*config = dlg.get_configurations();
		if (!save_options())
			QMessageBox::warning(this, "I/O Error ... ",
			"Please note that the changes could not be save\non the disk, as a result, the next time that the\napplication is loaded, all the current configurations\n will get reset. The new configuration will last by the\n end of the current session", "Ok", NULL, NULL
			,0,0);

	}
}
Beispiel #13
0
int main(int argc, char** argv) {
    // This program recursively finds and builds all files in the source
    // directory, and then generates the output in the lib/bin directory.
    env->workspace_load();
    env->output(".");
    env->make(true);
    env->monolithic_build(false);

    argp = new ArgParser(env, argc, argv);
    load_options(); 
    parse_options();
    save_options();

    Builder::Ptr builder(new Builder(env));
    return builder->errors();
}
Beispiel #14
0
BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND hw;
	char buff[512];

	switch ( msg ) {
	case WM_INITDIALOG: 
		{
			TranslateDialogDefault( hwndDlg );
			itoa(options.timeout, buff, 10);
			SetDlgItemText(hwndDlg, IDC_ED_TIMEOUT, buff);
			CheckDlgButton(hwndDlg, IDC_CHK_RECVONLY, options.monitor_recv_only ? TRUE : FALSE);
		}
		return TRUE;
	case WM_COMMAND:
		if ( HIWORD( wParam ) == BN_CLICKED ) {
			switch( LOWORD( wParam )) {
			case IDC_CHK_RECVONLY:
				SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
				break;
			}
		} else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
			SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
		}
		return TRUE;
	case WM_NOTIFY:
		if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
			hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
			GetWindowText(hw, buff, 512);
			if(strlen(buff) > 0)
				options.timeout = atoi(buff);
			options.monitor_recv_only = IsDlgButtonChecked(hwndDlg, IDC_CHK_RECVONLY);
			save_options();
			return TRUE;
		}
		break;
	}

	return FALSE;
}
Beispiel #15
0
void load_options()
{
    std::ifstream fin;
    fin.open("data/options.txt");
    if(!fin.is_open()) {
        fin.close();
        save_options();
        fin.open("data/options.txt");
        if(!fin.is_open()) {
            DebugLog() << "Could neither read nor create ./data/options.txt\n";
            return;
        }
    }

    while(!fin.eof()) {
        std::string sOption;
        fin >> sOption;

        if(sOption == "") {
            getline(fin, sOption);    // Empty line, chomp it

        } else if(sOption[0] == '#') { // # indicates a comment
            getline(fin, sOption);

        } else {
            std::string sValue;
            fin >> sValue;

            OPTIONS[sOption].setValue(sValue);
        }
    }

    fin.close();

    trigdist = false; // cache to global due to heavy usage.
    if(OPTIONS["CIRCLEDIST"]) {
        trigdist=true;
    }
}
Beispiel #16
0
/**************************************************************************
...
**************************************************************************/
void disconnect_from_server(void)
{
  const bool force = !client.conn.used;

  attribute_flush();
  /* If it's internal server - kill him 
   * We assume that we are always connected to the internal server  */
  if (!force) {
    client_kill_server(FALSE);
  }
  close_socket_nomessage(&client.conn);
  if (force) {
    client_kill_server(TRUE);
  }
  output_window_append(FTC_CLIENT_INFO, NULL,
                       _("Disconnected from server."));
  if (with_ggz) {
    client_exit();
  }
  if (save_options_on_exit) {
    save_options();
  }
}  
Beispiel #17
0
static gint delete_event( GtkWidget *widget, GdkEvent *event, gpointer data )
{
   save_options();
   g_print ("Thanks for using Linux Video Studio TV\n");
   return(FALSE);
}
Beispiel #18
0
void game::show_options()
{
    WINDOW* w_options_border = newwin(25, 80, (TERMY > 25) ? (TERMY-25)/2 : 0, (TERMX > 80) ? (TERMX-80)/2 : 0);
    WINDOW* w_options = newwin(23, 78, 1 + ((TERMY > 25) ? (TERMY-25)/2 : 0), 1 + ((TERMX > 80) ? (TERMX-80)/2 : 0));

    int offset = 1;
    const int MAX_LINE = 22;
    int line = 0;
    char ch = ' ';
    bool changed_options = false;
    bool needs_refresh = true;
    wborder(w_options_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
            LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX);
    mvwprintz(w_options_border, 0, 36, c_ltred, " OPTIONS ");
    wrefresh(w_options_border);
    do {
// TODO: change instructions
        if(needs_refresh) {
            werase(w_options);
            mvwprintz(w_options, 0, 40, c_white, "Use up/down keys to scroll through");
            mvwprintz(w_options, 1, 40, c_white, "available options.");
            mvwprintz(w_options, 2, 40, c_white, "Use left/right keys to toggle.");
            mvwprintz(w_options, 3, 40, c_white, "Press ESC or q to return.             ");
// highlight options for option descriptions
            std::string tmp = option_desc(option_key(offset + line));
            std::string out;
            size_t pos;
            int displayline = 5;
            do {
                pos = tmp.find_first_of('\n');
                out = tmp.substr(0, pos);
                mvwprintz(w_options, displayline, 40, c_white, out.c_str());
                tmp = tmp.substr(pos + 1);
                displayline++;
            } while(pos != std::string::npos && displayline < 12);
            needs_refresh = false;
        }

// Clear the lines
        for(int i = 0; i < 25; i++) {
            mvwprintz(w_options, i, 0, c_black, "                                        ");
        }
        int valid_option_count = 0;

// display options
        for(int i = 0; i < 26 && offset + i < NUM_OPTION_KEYS; i++) {
            valid_option_count++;
            mvwprintz(w_options, i, 0, c_white, "%s: ",
                      option_name(option_key(offset + i)).c_str());

            if(option_is_bool(option_key(offset + i))) {
                bool on = OPTIONS[ option_key(offset + i) ];
                if(i == line) {
                    mvwprintz(w_options, i, 30, hilite(c_ltcyan), (on ? "True" : "False"));
                } else {
                    mvwprintz(w_options, i, 30, (on ? c_ltgreen : c_ltred), (on ? "True" : "False"));
                }
            } else {
                char option_val = OPTIONS[ option_key(offset + i) ];
                if(i == line) {
                    mvwprintz(w_options, i, 30, hilite(c_ltcyan), "%d", option_val);
                } else {
                    mvwprintz(w_options, i, 30, c_ltgreen, "%d", option_val);
                }
            }
        }
        wrefresh(w_options);
        ch = input();
        needs_refresh = true;

        switch(ch) {
// move up and down
        case 'j':
            line++;
            if(line > MAX_LINE/2 && offset + 1 < NUM_OPTION_KEYS - MAX_LINE) {
                ++offset;
                --line;
            }
            if(line > MAX_LINE) {
                line = 0;
                offset = 1;
            }
            break;
        case 'k':
            line--;
            if(line < MAX_LINE/2 && offset > 1) {
                --offset;
                ++line;
            }
            if(line < 0) {
                line = MAX_LINE;
                offset = NUM_OPTION_KEYS - MAX_LINE - 1;
            }
            break;
// toggle options with left/right keys
        case 'h':
            if(option_is_bool(option_key(offset + line))) {
                OPTIONS[ option_key(offset + line) ] = !(OPTIONS[ option_key(offset + line) ]);
            } else {
                OPTIONS[ option_key(offset + line) ]--;
                if((OPTIONS[ option_key(offset + line) ]) < option_min_options(option_key(offset + line))) {
                    OPTIONS[ option_key(offset + line) ] = option_max_options(option_key(offset + line)) - 1;
                }
            }
            changed_options = true;
            break;
        case 'l':
            if(option_is_bool(option_key(offset + line))) {
                OPTIONS[ option_key(offset + line) ] = !(OPTIONS[ option_key(offset + line) ]);
            } else {
                OPTIONS[ option_key(offset + line) ]++;
                if((OPTIONS[ option_key(offset + line) ]) >= option_max_options(option_key(offset + line))) {
                    OPTIONS[ option_key(offset + line) ] = option_min_options(option_key(offset + line));
                }
            }
            changed_options = true;
            break;
        }
        if(changed_options && OPTIONS[OPT_SEASON_LENGTH] < 1) { OPTIONS[OPT_SEASON_LENGTH]=option_max_options(OPT_SEASON_LENGTH)-1; }
    } while(ch != 'q' && ch != 'Q' && ch != KEY_ESCAPE);

    if(changed_options && query_yn("Save changes?")) {
        save_options();
        trigdist=(OPTIONS[OPT_CIRCLEDIST] ? true : false);
    }
    werase(w_options);
}
 ~PlugReverb()
 {
    save_options("rarch_effect.cfg");
 }
Beispiel #20
0
void game::show_options()
{
    std::map<std::string, cOpt> OPTIONS_OLD = OPTIONS;

    const int iTooltipHeight = 3;
    const int iContentHeight = FULL_SCREEN_HEIGHT-3-iTooltipHeight;

    const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 0;
    const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 0;

    std::map<int, bool> mapLines;
    mapLines[3] = true;
    mapLines[60] = true;
    //mapLines[68] = true;

    WINDOW* w_options_border = newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, iOffsetY, iOffsetX);

    WINDOW* w_options_tooltip = newwin(iTooltipHeight, FULL_SCREEN_WIDTH - 2, 1 + iOffsetY, 1 + iOffsetX);
    WINDOW* w_options_header = newwin(1, FULL_SCREEN_WIDTH - 2, 1 + iTooltipHeight + iOffsetY, 1 + iOffsetX);
    WINDOW* w_options = newwin(iContentHeight, FULL_SCREEN_WIDTH - 2, iTooltipHeight + 2 + iOffsetY, 1 + iOffsetX);

    wborder(w_options_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX);
    mvwputch(w_options_border, 4,  0, c_ltgray, LINE_XXXO); // |-
    mvwputch(w_options_border, 4, 79, c_ltgray, LINE_XOXX); // -|

    for (std::map<int, bool>::iterator iter = mapLines.begin(); iter != mapLines.end(); ++iter) {
        mvwputch(w_options_border, FULL_SCREEN_HEIGHT-1, iter->first + 1, c_ltgray, LINE_XXOX); // _|_
    }

    mvwprintz(w_options_border, 0, 36, c_ltred, _(" OPTIONS "));
    wrefresh(w_options_border);

    for (int i = 0; i < 78; i++) {
        if (mapLines[i]) {
            mvwputch(w_options_header, 0, i, c_ltgray, LINE_OXXX);
        } else {
            mvwputch(w_options_header, 0, i, c_ltgray, LINE_OXOX); // Draw header line
        }
    }

    //mvwprintz(w_options_header, 3, 0, c_white, "#");
    //mvwprintz(w_options_header, 3, 7, c_white, _("Option"));
    //mvwprintz(w_options_header, 3, 52, c_white, _("Value"));

    wrefresh(w_options_header);

    int iCurrentPage = 0;
    int iCurrentLine = 0;
    int iStartPos = 0;
    bool bStuffChanged = false;
    char ch = ' ';

    std::stringstream sTemp;

    do {
        //Clear the lines
        for (int i = 0; i < iContentHeight; i++) {
            for (int j = 0; j < 79; j++) {
                if (mapLines[j]) {
                    mvwputch(w_options, i, j, c_ltgray, LINE_XOXO);
                } else {
                    mvwputch(w_options, i, j, c_black, ' ');
                }

                if (i < iTooltipHeight) {
                    mvwputch(w_options_tooltip, i, j, c_black, ' ');
                }
            }
        }

        if (mPageItems[iCurrentPage].size() > iContentHeight) {
            iStartPos = iCurrentLine - (iContentHeight - 1) / 2;

            if (iStartPos < 0) {
                iStartPos = 0;
            } else if (iStartPos + iContentHeight > mPageItems[iCurrentPage].size()) {
                iStartPos = mPageItems[iCurrentPage].size() - iContentHeight;
            }
        }

        //Draw options
        for (int i = iStartPos; i < mPageItems[iCurrentPage].size(); i++) {
            if (i >= iStartPos && i < iStartPos + ((iContentHeight > mPageItems[iCurrentPage].size()) ? mPageItems[iCurrentPage].size() : iContentHeight)) {
                nc_color cLineColor = c_ltgreen;

                sTemp.str("");
                sTemp << i + 1;
                mvwprintz(w_options, i - iStartPos, 0, c_white, sTemp.str().c_str());
                mvwprintz(w_options, i - iStartPos, 4, c_white, "");

                if (iCurrentLine == i) {
                    wprintz(w_options, c_yellow, ">> ");
                } else {
                    wprintz(w_options, c_yellow, "   ");
                }

                wprintz(w_options, c_white, "%s", (OPTIONS[mPageItems[iCurrentPage][i]].getMenuText()).c_str());

                if (OPTIONS[mPageItems[iCurrentPage][i]].getValue() == "False") {
                    cLineColor = c_ltred;
                }

                mvwprintz(w_options, i - iStartPos, 62, (iCurrentLine == i) ? hilite(cLineColor) : cLineColor, "%s", (OPTIONS[mPageItems[iCurrentPage][i]].getValue()).c_str());
            }
        }

        //Draw Tabs
        mvwprintz(w_options_header, 0, 7, c_white, "");
        for (int i = 0; i < vPages.size(); i++) {
            if (mPageItems[i].size() > 0) { //skip empty pages
                wprintz(w_options_header, c_white, "[");
                wprintz(w_options_header, (iCurrentPage == i) ? hilite(c_white) : c_white, vPages[i].c_str());
                wprintz(w_options_header, c_white, "]");
                wputch(w_options_header, c_white, LINE_OXOX);
            }
        }

        wrefresh(w_options_header);

        fold_and_print(w_options_tooltip, 0, 0, 78, c_white, "%s", (OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].getTooltip() + "  #Default: " + OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].getDefaultText()).c_str());
        wrefresh(w_options_tooltip);

        wrefresh(w_options);

        ch = input();

        if (mPageItems[iCurrentPage].size() > 0 || ch == '\t') {
            switch(ch) {
                case 'j': //move down
                    iCurrentLine++;
                    if (iCurrentLine >= mPageItems[iCurrentPage].size()) {
                        iCurrentLine = 0;
                    }
                    break;
                case 'k': //move up
                    iCurrentLine--;
                    if (iCurrentLine < 0) {
                        iCurrentLine = mPageItems[iCurrentPage].size()-1;
                    }
                    break;
                case 'l': //set to prev value
                    OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].setNext();
                    bStuffChanged = true;
                    break;
                case 'h': //set to next value
                    OPTIONS[mPageItems[iCurrentPage][iCurrentLine]].setPrev();
                    bStuffChanged = true;
                    break;
                case '>':
                case '\t': //Switch to next Page
                    iCurrentLine = 0;
                    do { //skip empty pages
                        iCurrentPage++;
                        if (iCurrentPage >= vPages.size()) {
                            iCurrentPage = 0;
                        }
                    } while(mPageItems[iCurrentPage].size() == 0);

                    break;
                case '<':
                    iCurrentLine = 0;
                    do { //skip empty pages
                        iCurrentPage--;
                        if (iCurrentPage < 0) {
                            iCurrentPage = vPages.size()-1;
                        }
                    } while(mPageItems[iCurrentPage].size() == 0);
                    break;
            }
        }
    } while(ch != 'q' && ch != 'Q' && ch != KEY_ESCAPE);

    if (bStuffChanged) {
        if(query_yn(_("Save changes?"))) {
            save_options();
        } else {
            OPTIONS = OPTIONS_OLD;
        }
    }

    werase(w_options);
    werase(w_options_border);
    werase(w_options_header);
    werase(w_options_tooltip);
}
Beispiel #21
0
void game::show_options()
{
 int iMaxX = (VIEWX < 12) ? 80 : (VIEWX*2)+56;
 int iMaxY = (VIEWY < 12) ? 25 : (VIEWY*2)+1;

 WINDOW* w_options_border = newwin(25, 80, (iMaxY > 25) ? (iMaxY-25)/2 : 0, (iMaxX > 80) ? (iMaxX-80)/2 : 0);
 WINDOW* w_options = newwin(23, 78, 1 + (int)((iMaxY > 25) ? (iMaxY-25)/2 : 0), 1 + (int)((iMaxX > 80) ? (iMaxX-80)/2 : 0));

 int offset = 1;
 int line = 0;
 char ch = ' ';
 bool changed_options = false;
 bool needs_refresh = true;
 do {
  wborder(w_options_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
                            LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX);
  mvwprintz(w_options_border, 0, 36, c_ltred, " OPTIONS ");
  wrefresh(w_options_border);

// TODO: change instructions
  if (needs_refresh) {
    werase(w_options);
    mvwprintz(w_options, 0, 40, c_white, "Use up/down keys to scroll through");
    mvwprintz(w_options, 1, 40, c_white, "available options.");
    mvwprintz(w_options, 2, 40, c_white, "Use left/right keys to toggle.");
    mvwprintz(w_options, 3, 40, c_white, "Press ESC or q to return.             ");
// highlight options for option descriptions
    std::string tmp = option_desc(option_key(offset + line));
    std::string out;
    size_t pos;
    int displayline = 5;
    do {
      pos = tmp.find_first_of('\n');
      out = tmp.substr(0, pos);
      mvwprintz(w_options, displayline, 40, c_white, out.c_str());
      tmp = tmp.substr(pos + 1);
      displayline++;
    } while (pos != std::string::npos && displayline < 12);
   needs_refresh = false;
  }

// Clear the lines
  for (int i = 0; i < 25; i++)
   mvwprintz(w_options, i, 0, c_black, "                                        ");
  int valid_option_count = 0;

// display options
  for (int i = 0; i < 25 && offset + i < NUM_OPTION_KEYS; i++)
  {
       valid_option_count++;
       mvwprintz(w_options, i, 0, c_white, "%s: ",
                option_name( option_key(offset + i) ).c_str());

      if (option_is_bool(option_key(offset + i)))
      {
        bool on = OPTIONS[ option_key(offset + i) ];
        if (i == line)
          mvwprintz(w_options, i, 30, hilite(c_ltcyan), (on ? "True" : "False"));
        else
          mvwprintz(w_options, i, 30, (on ? c_ltgreen : c_ltred), (on ? "True" : "False"));
      } else {
        char option_val = OPTIONS[ option_key(offset + i) ];
        if (i == line)
          mvwprintz(w_options, i, 30, hilite(c_ltcyan), "%d", option_val );
        else
          mvwprintz(w_options, i, 30, c_ltgreen, "%d", option_val );
      }
  }
  wrefresh(w_options);
  refresh();
  ch = input();
  needs_refresh = true;
  refresh();

 switch (ch) {
// move up and down
  case 'j':
   line++;
   if (line == NUM_OPTION_KEYS - 1)
    line = 0;
   break;
  case 'k':
   line--;
   if (line < 0)
    line = NUM_OPTION_KEYS - 2;
   break;
// toggle options with left/right keys
  case 'h':
      if (option_is_bool(option_key(offset + line)))
        OPTIONS[ option_key(offset + line) ] = !(OPTIONS[ option_key(offset + line) ]);
      else
      {
        OPTIONS[ option_key(offset + line) ]--;
        if ((OPTIONS[ option_key(offset + line) ]) < 0 )
          OPTIONS[ option_key(offset + line) ] = option_max_options(option_key(offset + line)) - 1;
      }
      changed_options = true;
  break;
  case 'l':
    if (option_is_bool(option_key(offset + line)))
      OPTIONS[ option_key(offset + line) ] = !(OPTIONS[ option_key(offset + line) ]);
    else
    {
      OPTIONS[ option_key(offset + line) ]++;
      if ((OPTIONS[ option_key(offset + line) ]) >= option_max_options(option_key(offset + line)))
        OPTIONS[ option_key(offset + line) ] = 0;
    }
    changed_options = true;
  break;
  }
 } while (ch != 'q' && ch != 'Q' && ch != KEY_ESCAPE);

 if (changed_options && query_yn(this->VIEWX, this->VIEWY, "Save changes?"))
  save_options();
 werase(w_options);
}
static void
save_and_hide (GthImportPreferencesDialog *self)
{
	save_options (self);
	gtk_widget_hide (GTK_WIDGET (self));
}
Beispiel #23
0
void game::show_options()
{
    // Remember what the options were originally so we can restore them if player cancels.
    option_table OPTIONS_OLD = OPTIONS;

    WINDOW* w_options_border = newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH,
                                      (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 0,
                                      (TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 0);
    WINDOW* w_options = newwin(FULL_SCREEN_HEIGHT-2, FULL_SCREEN_WIDTH-2,
                               1 + ((TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 0),
                               1 + ((TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 0));

    int offset = 1;
    const int MAX_LINE = 22;
    int line = 0;
    char ch = ' ';
    bool changed_options = false;
    bool needs_refresh = true;
    wborder(w_options_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
            LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX);
    mvwprintz(w_options_border, 0, 36, c_ltred, _(" OPTIONS "));
    wrefresh(w_options_border);
    do {
// TODO: change instructions
        if(needs_refresh) {
            werase(w_options);
            // because those texts use their own \n, do not fold so use a large enough width like 999
            fold_and_print(w_options, 0, 40, 999, c_white, _("Use up/down keys to scroll through\navailable options.\nUse left/right keys to toggle.\nPress ESC or q to return."));
// highlight options for option descriptions
            fold_and_print(w_options, 5, 40, 999, c_white, option_desc(option_key(offset + line)).c_str());
            needs_refresh = false;
        }

// Clear the lines
        for(int i = 0; i < 25; i++) {
            mvwprintz(w_options, i, 0, c_black, "                                        ");
        }
        int valid_option_count = 0;

// display options
        for(int i = 0; i < 26 && offset + i < NUM_OPTION_KEYS; i++) {
            valid_option_count++;
            mvwprintz(w_options, i, 0, c_white, "%s: ",
                      option_name(option_key(offset + i)).c_str());

            if(option_is_bool(option_key(offset + i))) {
                bool on = OPTIONS[ option_key(offset + i) ];
                if(i == line) {
                    mvwprintz(w_options, i, 30, hilite(c_ltcyan), (on ? _("True") : _("False")));
                } else {
                    mvwprintz(w_options, i, 30, (on ? c_ltgreen : c_ltred), (on ? _("True") : _("False")));
                }
            } else {
                char option_val = OPTIONS[ option_key(offset + i) ];
                if(i == line) {
                    mvwprintz(w_options, i, 30, hilite(c_ltcyan), "%d", option_val);
                } else {
                    mvwprintz(w_options, i, 30, c_ltgreen, "%d", option_val);
                }
            }
        }
        wrefresh(w_options);
        ch = input();
        needs_refresh = true;

        switch(ch) {
// move up and down
        case 'j':
            line++;
            if(line > MAX_LINE/2 && offset + 1 < NUM_OPTION_KEYS - MAX_LINE) {
                ++offset;
                --line;
            }
            if(line > MAX_LINE) {
                line = 0;
                offset = 1;
            }
            break;
        case 'k':
            line--;
            if(line < MAX_LINE/2 && offset > 1) {
                --offset;
                ++line;
            }
            if(line < 0) {
                line = MAX_LINE;
                offset = NUM_OPTION_KEYS - MAX_LINE - 1;
            }
            break;
// toggle options with left/right keys
        case 'h':
            if(option_is_bool(option_key(offset + line))) {
                OPTIONS[ option_key(offset + line) ] = !(OPTIONS[ option_key(offset + line) ]);
            } else {
                OPTIONS[ option_key(offset + line) ]--;
                if((OPTIONS[ option_key(offset + line) ]) < option_min_options(option_key(offset + line))) {
                    OPTIONS[ option_key(offset + line) ] = option_max_options(option_key(offset + line)) - 1;
                }
            }
            changed_options = true;
            break;
        case 'l':
            if(option_is_bool(option_key(offset + line))) {
                OPTIONS[ option_key(offset + line) ] = !(OPTIONS[ option_key(offset + line) ]);
            } else {
                OPTIONS[ option_key(offset + line) ]++;
                if((OPTIONS[ option_key(offset + line) ]) >= option_max_options(option_key(offset + line))) {
                    OPTIONS[ option_key(offset + line) ] = option_min_options(option_key(offset + line));
                }
            }
            changed_options = true;
            break;
        }
        if(changed_options && OPTIONS[OPT_SEASON_LENGTH] < 1) { OPTIONS[OPT_SEASON_LENGTH]=option_max_options(OPT_SEASON_LENGTH)-1; }
    } while(ch != 'q' && ch != 'Q' && ch != KEY_ESCAPE);

    if(changed_options)
    {
        if(query_yn(_("Save changes?")))
        {
            save_options();
            trigdist=(OPTIONS[OPT_CIRCLEDIST] ? true : false);
        }
        else
        {
            // Player wants to keep the old options. Revert!
            OPTIONS = OPTIONS_OLD;
        }
    }
    werase(w_options);
}
Beispiel #24
0
static void hndlmenu(int title, int item, int kstate)
{
	int qbutton; /* DjV 013 291202 */

	if ((menu[item].ob_state & DISABLED) == 0)
	{
		switch (item)
		{
		case MINFO:
			info();
			break;
		case MQUIT:
			/* DjV 013 291202 ---vvv--- */
			qbutton = alert_printf(3,QUITALRT); /* DjV 013 090203  shutdown revived */
			switch (qbutton)
			{
				case 3:
					break;
				case 2:
					shutdown=TRUE; /* no effect yet */
					/* break;DjV 013 090203 only without shutdown */
				case 1:      
			/* DjV 013 291202 ---^^^--- */
					menu_tnormal(menu, title, 1);
					quit = TRUE;
					break;
			}        /* DjV 013 291202 */
			break;
		case MOPTIONS:
			setpreferences();
			break;
		case MPRGOPT:
			prg_setprefs();
			break;
		case MSAVESET:
			save_options();
			break;
		case MLOADOPT:
			load_settings();
			break;
		case MSAVEAS:
			save_options_as();
			break;
		case MAPPLIK:
			app_install();
			break;
		case MIDSKICN:
			dsk_insticon();
			break;
		case MIWDICN:
			icnt_settypes();
			break;
		case MCHNGICN:
			dsk_chngicon();
			break;
		case MREMICON:
			dsk_remicon();
			break;
		case MEDITOR:
			set_editor();
			break;
		/* DjV 016 050103 ---vvv--- */	
		case MCOPTS:
			copyprefs();
			break;
		/* DjV 016 050103 ---^^^--- */
		case MWDOPT:
			dsk_options();
			break;
		/* DjV 007 250102 ---vvv--- */	
		case MVOPTS:
			chrez=voptions();
			if ( chrez ) quit=TRUE;
			break;
		/* DjV 007 250102 ---^^^--- */
		default:
			wd_hndlmenu(item, kstate);	/* handle all the rest in window.c */
			break;
		}
	}
	menu_tnormal(menu, title, 1);
}
Beispiel #25
0
void show_auto_pickup()
{
    save_reset_changes(false);

    const int iHeaderHeight = 4;
    const int iContentHeight = FULL_SCREEN_HEIGHT - 2 - iHeaderHeight;

    const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX - FULL_SCREEN_WIDTH) / 2 : 0;
    const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY - FULL_SCREEN_HEIGHT) / 2 : 0;

    std::map<int, bool> mapLines;
    mapLines[3] = true;
    mapLines[50] = true;
    mapLines[54] = true;

    const int iTotalCols = mapLines.size() - 1;

    WINDOW *w_auto_pickup_options = newwin(FULL_SCREEN_HEIGHT / 2, FULL_SCREEN_WIDTH / 2,
                                           iOffsetY + (FULL_SCREEN_HEIGHT / 2) / 2, iOffsetX + (FULL_SCREEN_WIDTH / 2) / 2);
    WINDOW *w_auto_pickup_help = newwin((FULL_SCREEN_HEIGHT / 2) - 2, FULL_SCREEN_WIDTH * 3 / 4,
                                        7 + iOffsetY + (FULL_SCREEN_HEIGHT / 2) / 2, iOffsetX + 19 / 2);

    WINDOW *w_auto_pickup_border = newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, iOffsetY, iOffsetX);
    WINDOW *w_auto_pickup_header = newwin(iHeaderHeight, FULL_SCREEN_WIDTH - 2, 1 + iOffsetY,
                                          1 + iOffsetX);
    WINDOW *w_auto_pickup = newwin(iContentHeight, FULL_SCREEN_WIDTH - 2, iHeaderHeight + 1 + iOffsetY,
                                   1 + iOffsetX);

    draw_border(w_auto_pickup_border);
    mvwputch(w_auto_pickup_border, 3,  0, c_ltgray, LINE_XXXO); // |-
    mvwputch(w_auto_pickup_border, 3, 79, c_ltgray, LINE_XOXX); // -|

    for (std::map<int, bool>::iterator iter = mapLines.begin(); iter != mapLines.end(); ++iter) {
        mvwputch(w_auto_pickup_border, FULL_SCREEN_HEIGHT - 1, iter->first + 1, c_ltgray, LINE_XXOX); // _|_
    }

    mvwprintz(w_auto_pickup_border, 0, 29, c_ltred, _(" AUTO PICKUP MANAGER "));
    wrefresh(w_auto_pickup_border);

    int tmpx = 0;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<A>dd")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<R>emove")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<C>opy")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<M>ove")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<E>nable")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<D>isable")) + 2;
    shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<T>est"));
    tmpx = 0;
    tmpx += shortcut_print(w_auto_pickup_header, 1, tmpx, c_white, c_ltgreen,
                           _("<+-> Move up/down")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 1, tmpx, c_white, c_ltgreen, _("<Enter>-Edit")) + 2;
    shortcut_print(w_auto_pickup_header, 1, tmpx, c_white, c_ltgreen, _("<Tab>-Switch Page"));

    for (int i = 0; i < 78; i++) {
        if (mapLines[i]) {
            mvwputch(w_auto_pickup_header, 2, i, c_ltgray, LINE_OXXX);
            mvwputch(w_auto_pickup_header, 3, i, c_ltgray, LINE_XOXO);
        } else {
            mvwputch(w_auto_pickup_header, 2, i, c_ltgray, LINE_OXOX); // Draw line under header
        }
    }

    mvwprintz(w_auto_pickup_header, 3, 0, c_white, "#");
    mvwprintz(w_auto_pickup_header, 3, 7, c_white, _("Rules"));
    mvwprintz(w_auto_pickup_header, 3, 51, c_white, _("I/E"));

    wrefresh(w_auto_pickup_header);

    int iCurrentPage = 1;
    int iCurrentLine = 0;
    int iCurrentCol = 1;
    int iStartPos = 0;
    bool bStuffChanged = false;
    char ch = ' ';

    std::stringstream sTemp;

    do {
        int locx = 17;
        locx += shortcut_print(w_auto_pickup_header, 2, locx, c_white,
                               (iCurrentPage == 1) ? hilite(c_white) : c_white, _("[<Global>]")) + 1;
        shortcut_print(w_auto_pickup_header, 2, locx, c_white,
                       (iCurrentPage == 2) ? hilite(c_white) : c_white, _("[<Character>]"));

        locx = 55;
        mvwprintz(w_auto_pickup_header, 0, locx, c_white, _("Auto pickup enabled:"));
        locx += shortcut_print(w_auto_pickup_header, 1, locx,
                               ((OPTIONS["AUTO_PICKUP"]) ? c_ltgreen : c_ltred), c_white,
                               ((OPTIONS["AUTO_PICKUP"]) ? _("True") : _("False")));
        locx += shortcut_print(w_auto_pickup_header, 1, locx, c_white, c_ltgreen, "  ");
        locx += shortcut_print(w_auto_pickup_header, 1, locx, c_white, c_ltgreen, _("<S>witch"));
        shortcut_print(w_auto_pickup_header, 1, locx, c_white, c_ltgreen, "  ");

        wrefresh(w_auto_pickup_header);

        // Clear the lines
        for (int i = 0; i < iContentHeight; i++) {
            for (int j = 0; j < 79; j++) {
                if (mapLines[j]) {
                    mvwputch(w_auto_pickup, i, j, c_ltgray, LINE_XOXO);
                } else {
                    mvwputch(w_auto_pickup, i, j, c_black, ' ');
                }
            }
        }

        if (iCurrentPage == 1 || iCurrentPage == 2) {
            if (iCurrentPage == 2 && g->u.name == "") {
                vAutoPickupRules[2].clear();
                mvwprintz(w_auto_pickup, 8, 15, c_white, _("Please load a character first to use this page!"));
            }

            //Draw Scrollbar
            draw_scrollbar(w_auto_pickup_border, iCurrentLine, iContentHeight,
                           vAutoPickupRules[iCurrentPage].size(), 5);

            calcStartPos(iStartPos, iCurrentLine, iContentHeight, vAutoPickupRules[iCurrentPage].size());

            // display auto pickup
            for (int i = iStartPos; i < vAutoPickupRules[iCurrentPage].size(); i++) {
                if (i >= iStartPos &&
                    i < iStartPos + ((iContentHeight > vAutoPickupRules[iCurrentPage].size()) ?
                                     vAutoPickupRules[iCurrentPage].size() : iContentHeight)) {
                    nc_color cLineColor = (vAutoPickupRules[iCurrentPage][i].bActive) ? c_white : c_ltgray;

                    sTemp.str("");
                    sTemp << i + 1;
                    mvwprintz(w_auto_pickup, i - iStartPos, 0, cLineColor, "%s", sTemp.str().c_str());
                    mvwprintz(w_auto_pickup, i - iStartPos, 4, cLineColor, "");

                    if (iCurrentLine == i) {
                        wprintz(w_auto_pickup, c_yellow, ">> ");
                    } else {
                        wprintz(w_auto_pickup, c_yellow, "   ");
                    }

                    wprintz(w_auto_pickup, (iCurrentLine == i &&
                                            iCurrentCol == 1) ? hilite(cLineColor) : cLineColor, "%s",
                            ((vAutoPickupRules[iCurrentPage][i].sRule == "") ? _("<empty rule>") :
                             vAutoPickupRules[iCurrentPage][i].sRule).c_str());

                    mvwprintz(w_auto_pickup, i - iStartPos, 52, (iCurrentLine == i &&
                              iCurrentCol == 2) ? hilite(cLineColor) : cLineColor, "%s",
                              ((vAutoPickupRules[iCurrentPage][i].bExclude) ? rm_prefix(_("<Exclude>E")).c_str() : rm_prefix(
                                   _("<Include>I")).c_str()));
                }
            }

            wrefresh(w_auto_pickup);

        } else if (iCurrentPage == 3) {
            draw_border(w_auto_pickup_options);

            mvwprintz(w_auto_pickup_options, 5, 10, c_white, _("Under construction!"));

            wrefresh(w_auto_pickup);
            wrefresh(w_auto_pickup_options);
        }

        ch = (char)input();

        if (iCurrentPage == 3) {
            switch(ch) {
            case '\t': //Switch to next Page
                iCurrentPage++;
                if (iCurrentPage > 3) {
                    iCurrentPage = 1;
                    iCurrentLine = 0;
                }
                break;
            }
        } else if (iCurrentPage == 1 || iCurrentPage == 2) {
            if (iCurrentPage == 2 && g->u.name == "" && ch != '\t') {
                //Only allow loaded games to use the char sheet
            } else if (vAutoPickupRules[iCurrentPage].size() > 0 || ch == 'a' || ch == 'A' || ch == 's' ||
                       ch == 'S' || ch == '\t') {
                switch(ch) {
                case 'j': //move down
                    iCurrentLine++;
                    iCurrentCol = 1;
                    if (iCurrentLine >= vAutoPickupRules[iCurrentPage].size()) {
                        iCurrentLine = 0;
                    }
                    break;
                case 'k': //move up
                    iCurrentLine--;
                    iCurrentCol = 1;
                    if (iCurrentLine < 0) {
                        iCurrentLine = vAutoPickupRules[iCurrentPage].size() - 1;
                    }
                    break;
                case 'a': //add new rule
                case 'A':
                    bStuffChanged = true;
                    vAutoPickupRules[iCurrentPage].push_back(cPickupRules("", true, false));
                    iCurrentLine = vAutoPickupRules[iCurrentPage].size() - 1;
                    break;
                case 'r': //remove rule
                case 'R':
                    bStuffChanged = true;
                    vAutoPickupRules[iCurrentPage].erase(vAutoPickupRules[iCurrentPage].begin() + iCurrentLine);
                    if (iCurrentLine > vAutoPickupRules[iCurrentPage].size() - 1) {
                        iCurrentLine--;
                    }
                    break;
                case 'c': //copy rule
                case 'C':
                    bStuffChanged = true;
                    vAutoPickupRules[iCurrentPage].push_back(cPickupRules(
                                vAutoPickupRules[iCurrentPage][iCurrentLine].sRule,
                                vAutoPickupRules[iCurrentPage][iCurrentLine].bActive,
                                vAutoPickupRules[iCurrentPage][iCurrentLine].bExclude));
                    iCurrentLine = vAutoPickupRules[iCurrentPage].size() - 1;
                    break;
                case 'm': //move rule global <-> character
                case 'M':
                    if ((iCurrentPage == 1 && g->u.name != "") || iCurrentPage == 2) {
                        bStuffChanged = true;
                        //copy over
                        vAutoPickupRules[(iCurrentPage == 1) ? 2 : 1].push_back(cPickupRules(
                                    vAutoPickupRules[iCurrentPage][iCurrentLine].sRule,
                                    vAutoPickupRules[iCurrentPage][iCurrentLine].bActive,
                                    vAutoPickupRules[iCurrentPage][iCurrentLine].bExclude));

                        //remove old
                        vAutoPickupRules[iCurrentPage].erase(vAutoPickupRules[iCurrentPage].begin() + iCurrentLine);
                        iCurrentLine = vAutoPickupRules[(iCurrentPage == 1) ? 2 : 1].size() - 1;
                        iCurrentPage = (iCurrentPage == 1) ? 2 : 1;
                    }
                    break;
                case '\t': //Switch to next Page
                    iCurrentPage++;
                    if (iCurrentPage > 2) {
                        iCurrentPage = 1;
                        iCurrentLine = 0;
                    }
                    break;
                case '\n': //Edit Col in current line
                    bStuffChanged = true;
                    if (iCurrentCol == 1) {
                        fold_and_print(w_auto_pickup_help, 1, 1, 999, c_white,
                                       _(
                                           "* is used as a Wildcard. A few Examples:\n"
                                           "\n"
                                           "wood arrow    matches the itemname exactly\n"
                                           "wood ar*      matches items beginning with wood ar\n"
                                           "*rrow         matches items ending with rrow\n"
                                           "*avy fle*fi*arrow     multible * are allowed\n"
                                           "heAVY*woOD*arrOW      case insesitive search\n"
                                           "")
                                      );

                        draw_border(w_auto_pickup_help);
                        wrefresh(w_auto_pickup_help);
                        vAutoPickupRules[iCurrentPage][iCurrentLine].sRule = trim_rule(string_input_popup(_("Pickup Rule:"),
                                30, vAutoPickupRules[iCurrentPage][iCurrentLine].sRule));
                    } else if (iCurrentCol == 2) {
                        vAutoPickupRules[iCurrentPage][iCurrentLine].bExclude =
                            !vAutoPickupRules[iCurrentPage][iCurrentLine].bExclude;
                    }
                    break;
                case 'e': //enable rule
                case 'E':
                    bStuffChanged = true;
                    vAutoPickupRules[iCurrentPage][iCurrentLine].bActive = true;
                    break;
                case 'd': //disable rule
                case 'D':
                    bStuffChanged = true;
                    vAutoPickupRules[iCurrentPage][iCurrentLine].bActive = false;
                    break;
                case 'h': //move left
                    iCurrentCol--;
                    if (iCurrentCol < 1) {
                        iCurrentCol = iTotalCols;
                    }
                    break;
                case 'l': //move right
                    iCurrentCol++;
                    if (iCurrentCol > iTotalCols) {
                        iCurrentCol = 1;
                    }
                    break;
                case '+': //move rule up
                    bStuffChanged = true;
                    if (iCurrentLine < vAutoPickupRules[iCurrentPage].size() - 1) {
                        std::swap(vAutoPickupRules[iCurrentPage][iCurrentLine],
                                  vAutoPickupRules[iCurrentPage][iCurrentLine + 1]);
                        iCurrentLine++;
                        iCurrentCol = 1;
                    }
                    break;
                case '-': //move rule down
                    bStuffChanged = true;
                    if (iCurrentLine > 0) {
                        std::swap(vAutoPickupRules[iCurrentPage][iCurrentLine],
                                  vAutoPickupRules[iCurrentPage][iCurrentLine - 1]);
                        iCurrentLine--;
                        iCurrentCol = 1;
                    }
                    break;
                case 't': //test rule
                case 'T':
                    test_pattern(iCurrentPage, iCurrentLine);
                    break;
                case 'S': //Switch auto pickup option (enabled/disabled)
                case 's':
                    OPTIONS["AUTO_PICKUP"].setNext();
                    save_options((g->u.name != ""));
                    break;
                }
            }
        }
    } while(ch != 'q' && ch != 'Q' && ch != KEY_ESCAPE);

    if (bStuffChanged) {
        if(query_yn(_("Save changes?"))) {
            save_auto_pickup(false);

            if (g->u.name != "") {
                save_auto_pickup(true);
            }
        } else {
            save_reset_changes(true);
        }
    }

    werase(w_auto_pickup);
    werase(w_auto_pickup_border);
    werase(w_auto_pickup_header);
    werase(w_auto_pickup_options);
    werase(w_auto_pickup_help);
}
void show_auto_pickup()
{
    save_reset_changes(false);

    const int iHeaderHeight = 4;
    const int iContentHeight = FULL_SCREEN_HEIGHT - 2 - iHeaderHeight;

    const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX - FULL_SCREEN_WIDTH) / 2 : 0;
    const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY - FULL_SCREEN_HEIGHT) / 2 : 0;

    std::map<int, bool> mapLines;
    mapLines[4] = true;
    mapLines[50] = true;
    mapLines[54] = true;

    const int iTotalCols = mapLines.size() - 1;

    WINDOW *w_auto_pickup_help = newwin((FULL_SCREEN_HEIGHT / 2) - 2, FULL_SCREEN_WIDTH * 3 / 4,
                                        7 + iOffsetY + (FULL_SCREEN_HEIGHT / 2) / 2, iOffsetX + 19 / 2);
    WINDOW_PTR w_auto_pickup_helpptr( w_auto_pickup_help );

    WINDOW *w_auto_pickup_border = newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, iOffsetY, iOffsetX);
    WINDOW_PTR w_auto_pickup_borderptr( w_auto_pickup_border );
    WINDOW *w_auto_pickup_header = newwin(iHeaderHeight, FULL_SCREEN_WIDTH - 2, 1 + iOffsetY,
                                          1 + iOffsetX);
    WINDOW_PTR w_auto_pickup_headerptr( w_auto_pickup_header );
    WINDOW *w_auto_pickup = newwin(iContentHeight, FULL_SCREEN_WIDTH - 2, iHeaderHeight + 1 + iOffsetY,
                                   1 + iOffsetX);
    WINDOW_PTR w_auto_pickupptr( w_auto_pickup );

    draw_border(w_auto_pickup_border);
    mvwputch(w_auto_pickup_border, 3,  0, c_ltgray, LINE_XXXO); // |-
    mvwputch(w_auto_pickup_border, 3, 79, c_ltgray, LINE_XOXX); // -|

    for( auto &mapLine : mapLines ) {
        mvwputch( w_auto_pickup_border, FULL_SCREEN_HEIGHT - 1, mapLine.first + 1, c_ltgray,
                  LINE_XXOX ); // _|_
    }

    mvwprintz(w_auto_pickup_border, 0, 29, c_ltred, _(" AUTO PICKUP MANAGER "));
    wrefresh(w_auto_pickup_border);

    int tmpx = 0;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<A>dd")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<R>emove")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<C>opy")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<M>ove")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<E>nable")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<D>isable")) + 2;
    shortcut_print(w_auto_pickup_header, 0, tmpx, c_white, c_ltgreen, _("<T>est"));
    tmpx = 0;
    tmpx += shortcut_print(w_auto_pickup_header, 1, tmpx, c_white, c_ltgreen,
                           _("<+-> Move up/down")) + 2;
    tmpx += shortcut_print(w_auto_pickup_header, 1, tmpx, c_white, c_ltgreen, _("<Enter>-Edit")) + 2;
    shortcut_print(w_auto_pickup_header, 1, tmpx, c_white, c_ltgreen, _("<Tab>-Switch Page"));

    for (int i = 0; i < 78; i++) {
        if (mapLines[i]) {
            mvwputch(w_auto_pickup_header, 2, i, c_ltgray, LINE_OXXX);
            mvwputch(w_auto_pickup_header, 3, i, c_ltgray, LINE_XOXO);
        } else {
            mvwputch(w_auto_pickup_header, 2, i, c_ltgray, LINE_OXOX); // Draw line under header
        }
    }

    mvwprintz(w_auto_pickup_header, 3, 1, c_white, "#");
    mvwprintz(w_auto_pickup_header, 3, 8, c_white, _("Rules"));
    mvwprintz(w_auto_pickup_header, 3, 51, c_white, _("I/E"));

    wrefresh(w_auto_pickup_header);

    int iCurrentPage = 1;
    int iCurrentLine = 0;
    int iCurrentCol = 1;
    int iStartPos = 0;
    bool bStuffChanged = false;
    input_context ctxt("AUTO_PICKUP");
    ctxt.register_cardinal();
    ctxt.register_action("CONFIRM");
    ctxt.register_action("QUIT");
    ctxt.register_action("NEXT_TAB");
    ctxt.register_action("PREV_TAB");
    ctxt.register_action("ADD_RULE");
    ctxt.register_action("REMOVE_RULE");
    ctxt.register_action("COPY_RULE");
    ctxt.register_action("SWAP_RULE_GLOBAL_CHAR");
    ctxt.register_action("ENABLE_RULE");
    ctxt.register_action("DISABLE_RULE");
    ctxt.register_action("MOVE_RULE_UP");
    ctxt.register_action("MOVE_RULE_DOWN");
    ctxt.register_action("TEST_RULE");
    ctxt.register_action("SWITCH_AUTO_PICKUP_OPTION");
    ctxt.register_action("HELP_KEYBINDINGS");

    std::stringstream sTemp;

    while(true) {
        int locx = 17;
        locx += shortcut_print(w_auto_pickup_header, 2, locx, c_white,
                               (iCurrentPage == 1) ? hilite(c_white) : c_white, _("[<Global>]")) + 1;
        shortcut_print(w_auto_pickup_header, 2, locx, c_white,
                       (iCurrentPage == 2) ? hilite(c_white) : c_white, _("[<Character>]"));

        locx = 55;
        mvwprintz(w_auto_pickup_header, 0, locx, c_white, _("Auto pickup enabled:"));
        locx += shortcut_print(w_auto_pickup_header, 1, locx,
                               ((OPTIONS["AUTO_PICKUP"]) ? c_ltgreen : c_ltred), c_white,
                               ((OPTIONS["AUTO_PICKUP"]) ? _("True") : _("False")));
        locx += shortcut_print(w_auto_pickup_header, 1, locx, c_white, c_ltgreen, "  ");
        locx += shortcut_print(w_auto_pickup_header, 1, locx, c_white, c_ltgreen, _("<S>witch"));
        shortcut_print(w_auto_pickup_header, 1, locx, c_white, c_ltgreen, "  ");

        wrefresh(w_auto_pickup_header);

        // Clear the lines
        for (int i = 0; i < iContentHeight; i++) {
            for (int j = 0; j < 79; j++) {
                if (mapLines[j]) {
                    mvwputch(w_auto_pickup, i, j, c_ltgray, LINE_XOXO);
                } else {
                    mvwputch(w_auto_pickup, i, j, c_black, ' ');
                }
            }
        }

        const bool currentPageNonEmpty = !vAutoPickupRules[iCurrentPage].empty();

        if (iCurrentPage == 2 && g->u.name == "") {
            vAutoPickupRules[2].clear();
            mvwprintz(w_auto_pickup, 8, 15, c_white,
                      _("Please load a character first to use this page!"));
        }

        //Draw Scrollbar
        draw_scrollbar(w_auto_pickup_border, iCurrentLine, iContentHeight,
                       vAutoPickupRules[iCurrentPage].size(), 5);

        calcStartPos(iStartPos, iCurrentLine, iContentHeight,
                     vAutoPickupRules[iCurrentPage].size());

        // display auto pickup
        for (int i = iStartPos; i < (int)vAutoPickupRules[iCurrentPage].size(); i++) {
            if (i >= iStartPos &&
                i < iStartPos + ((iContentHeight > (int)vAutoPickupRules[iCurrentPage].size()) ?
                                 (int)vAutoPickupRules[iCurrentPage].size() : iContentHeight)) {
                nc_color cLineColor = (vAutoPickupRules[iCurrentPage][i].bActive) ?
                                      c_white : c_ltgray;

                sTemp.str("");
                sTemp << i + 1;
                mvwprintz(w_auto_pickup, i - iStartPos, 1, cLineColor, "%s", sTemp.str().c_str());
                mvwprintz(w_auto_pickup, i - iStartPos, 5, cLineColor, "");

                if (iCurrentLine == i) {
                    wprintz(w_auto_pickup, c_yellow, ">> ");
                } else {
                    wprintz(w_auto_pickup, c_yellow, "   ");
                }

                wprintz(w_auto_pickup, (iCurrentLine == i &&
                                        iCurrentCol == 1) ? hilite(cLineColor) : cLineColor, "%s",
                        ((vAutoPickupRules[iCurrentPage][i].sRule == "") ? _("<empty rule>") :
                         vAutoPickupRules[iCurrentPage][i].sRule).c_str());

                mvwprintz(w_auto_pickup, i - iStartPos, 52, (iCurrentLine == i &&
                          iCurrentCol == 2) ? hilite(cLineColor) : cLineColor, "%s",
                          ((vAutoPickupRules[iCurrentPage][i].bExclude) ? rm_prefix(_("<Exclude>E")).c_str() : rm_prefix(
                               _("<Include>I")).c_str()));
            }
        }

        wrefresh(w_auto_pickup);

        const std::string action = ctxt.handle_input();

        if (action == "NEXT_TAB") {
            iCurrentPage++;
            if (iCurrentPage > 2) {
                iCurrentPage = 1;
                iCurrentLine = 0;
            }
        } else if (action == "PREV_TAB") {
            iCurrentPage--;
            if (iCurrentPage < 1) {
                iCurrentPage = 2;
                iCurrentLine = 0;
            }
        } else if (action == "QUIT") {
            break;
        } else if (iCurrentPage == 2 && g->u.name.empty()) {
            //Only allow loaded games to use the char sheet
        } else if (action == "DOWN") {
            iCurrentLine++;
            iCurrentCol = 1;
            if (iCurrentLine >= (int)vAutoPickupRules[iCurrentPage].size()) {
                iCurrentLine = 0;
            }
        } else if (action == "UP") {
            iCurrentLine--;
            iCurrentCol = 1;
            if (iCurrentLine < 0) {
                iCurrentLine = vAutoPickupRules[iCurrentPage].size() - 1;
            }
        } else if (action == "ADD_RULE") {
            bStuffChanged = true;
            vAutoPickupRules[iCurrentPage].push_back(cPickupRules("", true, false));
            iCurrentLine = vAutoPickupRules[iCurrentPage].size() - 1;
        } else if (action == "REMOVE_RULE" && currentPageNonEmpty) {
            bStuffChanged = true;
            vAutoPickupRules[iCurrentPage].erase(vAutoPickupRules[iCurrentPage].begin() + iCurrentLine);
            if (iCurrentLine > (int)vAutoPickupRules[iCurrentPage].size() - 1) {
                iCurrentLine--;
            }
            if(iCurrentLine < 0){
                iCurrentLine = 0;
            }
        } else if (action == "COPY_RULE" && currentPageNonEmpty) {
            bStuffChanged = true;
            vAutoPickupRules[iCurrentPage].push_back(cPickupRules(
                        vAutoPickupRules[iCurrentPage][iCurrentLine].sRule,
                        vAutoPickupRules[iCurrentPage][iCurrentLine].bActive,
                        vAutoPickupRules[iCurrentPage][iCurrentLine].bExclude));
            iCurrentLine = vAutoPickupRules[iCurrentPage].size() - 1;
        } else if (action == "SWAP_RULE_GLOBAL_CHAR" && currentPageNonEmpty) {
            if ((iCurrentPage == 1 && g->u.name != "") || iCurrentPage == 2) {
                bStuffChanged = true;
                //copy over
                vAutoPickupRules[(iCurrentPage == 1) ? 2 : 1].push_back(cPickupRules(
                            vAutoPickupRules[iCurrentPage][iCurrentLine].sRule,
                            vAutoPickupRules[iCurrentPage][iCurrentLine].bActive,
                            vAutoPickupRules[iCurrentPage][iCurrentLine].bExclude));

                //remove old
                vAutoPickupRules[iCurrentPage].erase(vAutoPickupRules[iCurrentPage].begin() + iCurrentLine);
                iCurrentLine = vAutoPickupRules[(iCurrentPage == 1) ? 2 : 1].size() - 1;
                iCurrentPage = (iCurrentPage == 1) ? 2 : 1;
            }
        } else if (action == "CONFIRM" && currentPageNonEmpty) {
            bStuffChanged = true;
            if (iCurrentCol == 1) {
                fold_and_print(w_auto_pickup_help, 1, 1, 999, c_white,
                               _(
                                   "* is used as a Wildcard. A few Examples:\n"
                                   "\n"
                                   "wooden arrow    matches the itemname exactly\n"
                                   "wooden ar*      matches items beginning with wood ar\n"
                                   "*rrow           matches items ending with rrow\n"
                                   "*avy fle*fi*arrow     multiple * are allowed\n"
                                   "heAVY*woOD*arrOW      case insensitive search\n"
                                   "")
                              );

                draw_border(w_auto_pickup_help);
                wrefresh(w_auto_pickup_help);
                vAutoPickupRules[iCurrentPage][iCurrentLine].sRule = trim_rule(string_input_popup(_("Pickup Rule:"),
                        30, vAutoPickupRules[iCurrentPage][iCurrentLine].sRule));
            } else if (iCurrentCol == 2) {
                vAutoPickupRules[iCurrentPage][iCurrentLine].bExclude =
                    !vAutoPickupRules[iCurrentPage][iCurrentLine].bExclude;
            }
        } else if (action == "ENABLE_RULE" && currentPageNonEmpty) {
            bStuffChanged = true;
            vAutoPickupRules[iCurrentPage][iCurrentLine].bActive = true;
        } else if (action == "DISABLE_RULE" && currentPageNonEmpty) {
            bStuffChanged = true;
            vAutoPickupRules[iCurrentPage][iCurrentLine].bActive = false;
        } else if (action == "LEFT") {
            iCurrentCol--;
            if (iCurrentCol < 1) {
                iCurrentCol = iTotalCols;
            }
        } else if (action == "RIGHT") {
            iCurrentCol++;
            if (iCurrentCol > iTotalCols) {
                iCurrentCol = 1;
            }
        } else if (action == "MOVE_RULE_UP" && currentPageNonEmpty) {
            bStuffChanged = true;
            if (iCurrentLine < (int)vAutoPickupRules[iCurrentPage].size() - 1) {
                std::swap(vAutoPickupRules[iCurrentPage][iCurrentLine],
                          vAutoPickupRules[iCurrentPage][iCurrentLine + 1]);
                iCurrentLine++;
                iCurrentCol = 1;
            }
        } else if (action == "MOVE_RULE_DOWN" && currentPageNonEmpty) {
            bStuffChanged = true;
            if (iCurrentLine > 0) {
                std::swap(vAutoPickupRules[iCurrentPage][iCurrentLine],
                          vAutoPickupRules[iCurrentPage][iCurrentLine - 1]);
                iCurrentLine--;
                iCurrentCol = 1;
            }
        } else if (action == "TEST_RULE" && currentPageNonEmpty) {
            test_pattern(iCurrentPage, iCurrentLine);
        } else if (action == "SWITCH_AUTO_PICKUP_OPTION") {
            OPTIONS["AUTO_PICKUP"].setNext();
            save_options((g->u.name != ""));
        }
    }

    if (bStuffChanged) {
        if(query_yn(_("Save changes?"))) {
            save_auto_pickup(false);

            if (g->u.name != "") {
                save_auto_pickup(true);
            }
        } else {
            save_reset_changes(true);
        }
    }
}
options()
{
	/** change options... **/
	/* return:
	 *	> 0	if restort was done - to indicate we might need to
	 *	 	change the page of our headers as a consequence
	 *		of the new sort order
	 *	< 0	if user entered 'x' to quit elm immediately
	 *	0	otherwise
	 */

	int	ch,
	     	resort = 0;
	char	*strcpy(),
	     	temp[SLEN];	/* needed when an option is run through
				 * expand_env(), because that function
				 * is destructive of the original
				 */

	display_options();

	clearerr(stdin);

	while(1) {
	  ClearLine(LINES-4);

	  Centerline(LINES-4,
 "Select first letter of option line, '>' to save, or 'i' to return to index.");

	  PutLine0(LINES-2, 0, "Command: ");

	  ch = ReadCh();
	  ch = tolower(ch);

	  clear_error();	/* remove possible "sorting" message etc... */

	  one_liner(one_liner_for(ch));

	  switch (ch) {
	    case 'c' : optionally_enter(raw_calendar_file, 2, 23, FALSE, FALSE);
		       strcpy(temp, raw_calendar_file);
		       expand_env(calendar_file, temp);
		       break;
	    case 'd' : optionally_enter(raw_pager, 3, 23, FALSE, FALSE);
		       strcpy(temp, raw_pager);
		       expand_env(pager, temp);
		       clear_pages = (equal(pager, "builtin+") ||
			             equal(pager, "internal+"));
		       break;
	    case 'e' : optionally_enter(raw_editor, 4, 23, FALSE, FALSE);
		       strcpy(temp, raw_editor);
		       expand_env(editor, temp);
	               break;
	    case 'f' : optionally_enter(raw_folders, 5, 23, FALSE, FALSE);
		       strcpy(temp, raw_folders);
		       expand_env(folders, temp);
		       break;
	    case 's' : if(change_sort(6,23)) resort++;			break;
	    case 'o' : optionally_enter(raw_sentmail, 7, 23, FALSE, FALSE);
		       strcpy(temp, raw_sentmail);
		       expand_env(sent_mail, temp);
		       break;
	    case 'p' : optionally_enter(raw_printout, 8, 23, FALSE, FALSE);
		       strcpy(temp, raw_printout);
		       expand_env(printout, temp);
		       break;
	    case 'y' : optionally_enter(full_username, 9, 23, FALSE, FALSE);
		       break;
	    case 'a' : on_or_off(&arrow_cursor, 12, 23); 		break;
	    case 'm' : on_or_off(&mini_menu, 13, 23);
		       headers_per_page = LINES - (mini_menu ? 13 : 8); break;

	    case 'u' : switch_user_level(&user_level,15, 23);		break;
	    case 'n' : on_or_off(&names_only, 16, 23);			break;

	    case '?' : options_help();
	               PutLine0(LINES-2,0,"Command: ");			break;

	    case '>' : printf("Save options in .elm/elmrc...");
		       fflush(stdout);    save_options();		break;

	    case 'x' :	return(-1);	/* exit elm */
	    case 'q' :	/* pop back up to previous level, in this case == 'i' */
	    case 'i' :  /* return to index screen */
			return(resort ? 1 : 0);
	    case ctrl('L'): display_options();				break;
	    default: error("Command unknown!");
	  }

	}
}
Beispiel #28
0
static void save_list(GtkWidget *widget, GtkCList *clist)
{
   int i;
   char *data[2];
   GList *channellist = NULL;

   if (channels)
   {
      for(i=0;channels[i];i++)
         free(channels[i]);
      free(channels);
   }

   if (clist->rows)
      channels = (Channel**)malloc(sizeof(Channel*)*(clist->rows+1));
   for (i=0;i<clist->rows;i++)
   {
      channels[i] = (Channel*)malloc(sizeof(Channel));
      gtk_clist_get_text(clist, i, 0, &data[0]);
      gtk_clist_get_text(clist, i, 1, &data[1]);
      sprintf(channels[i]->name, data[0]);
      channels[i]->frequency = atoi(data[1]);
   }
   if (clist->rows)
      channels[clist->rows] = NULL;

   if (channels)
   {
      for (i=0;channels[i];i++)
         channellist = g_list_append(channellist, channels[i]->name);
   }
   if (channellist && channelcombo)
   {
      gtk_combo_set_popdown_strings (GTK_COMBO (channelcombo), channellist);
   }

#ifdef HAVE_LIRC
   for (i=0;i<RC_NUM_KEYS;i++)
      remote_buttons[i] = g_strdup(gtk_entry_get_text(GTK_ENTRY(rc_entry[i])));

   if (strcmp(lirc_dev, gtk_entry_get_text(GTK_ENTRY(lirc_device_entry))))
   {
      lirc_dev = g_strdup(gtk_entry_get_text(GTK_ENTRY(lirc_device_entry)));
      lirc_init();
   }
#endif

#ifdef OSS
   if (strcmp(mixer_dev, gtk_entry_get_text(GTK_ENTRY(mixer_device_entry))))
   {
      mixer_dev = g_strdup(gtk_entry_get_text(GTK_ENTRY(mixer_device_entry)));
      sound_init();
   }
   for (i=0;(uint)i<g_list_length(audio_src_list);i++)
   {
      if (!strcmp((char *)g_list_nth_data(audio_src_list, i),
         gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(audio_src_combo)->entry))))
      {
         audio_src = i;
      }
   }
#endif

   if (port != atoi(gtk_entry_get_text(GTK_ENTRY(v4lxv_port_entry))))
   {
      port = atoi(gtk_entry_get_text(GTK_ENTRY(v4lxv_port_entry)));
      gtk_tvplug_set(tv, "port", port);
   }

   for (i=0;(uint)i<g_list_length(GTK_TVPLUG(tv)->encoding_list);i++)
   {
      if (!strcmp(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(v4lxv_encoding_combo)->entry)),
         (char *) g_list_nth_data(GTK_TVPLUG(tv)->encoding_list, i)))
      {
         gtk_tvplug_set(tv, "encoding", i);
         encoding_id = i;
      }
   }

   save_options();
}
 ~PlugEQ()
 {
    save_options("rarch_effect.cfg");
    dsp_eq_free(eq_l);
    dsp_eq_free(eq_r);
 }
Beispiel #30
0
LRESULT CALLBACK options_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
	static HWND grippy=0;
	switch(msg)
	{
	case WM_INITDIALOG:
		grippy=create_grippy(hwnd);
		init_options_win_anchor(hwnd);
		restore_options_rel_pos(hwnd);
		SendDlgItemMessage(hwnd,IDC_MATCH_PREFIX_LEN,EM_LIMITTEXT,4,0);
		populate_options(hwnd);
		return 0;
	case WM_DESTROY:
		save_options_rel_pos(hwnd);
		break;
	case WM_SIZE:
		grippy_move(hwnd,grippy);
		resize_options(hwnd);
		InvalidateRect(hwnd,NULL,TRUE);
		break;
	case WM_DRAWITEM:
		break;
	case WM_HELP:
		show_options_help(hwnd);
		return TRUE;
		break;
	case WM_COMMAND:
		switch(LOWORD(wparam)){
		case IDC_SELECT_OPEN:
			if(HIWORD(wparam)==CBN_SELENDOK)
				populate_caption_open(hwnd);
			break;
		case IDC_COMBO_FONT:
			if(HIWORD(wparam)==CBN_SELENDOK){
				int font;
				char str[80]={0};
				GetDlgItemText(hwnd,IDC_COMBO_FONT,str,sizeof(str));
				font=fontname_to_int(str);
				SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_SEARCH,WM_SETFONT,GetStockObject(font),0);
				SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_REPLACE,WM_SETFONT,GetStockObject(font),0);
				SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_PATH,WM_SETFONT,GetStockObject(font),0);
				SendDlgItemMessage(GetParent(hwnd),IDC_COMBO_MASK,WM_SETFONT,GetStockObject(font),0);
			}
			break;
		case IDC_LISTBOX_FONT:
			if(HIWORD(wparam)==CBN_SELENDOK){
				int font;
				char str[80]={0};
				GetDlgItemText(hwnd,IDC_LISTBOX_FONT,str,sizeof(str));
				font=fontname_to_int(str);
				SendDlgItemMessage(GetParent(hwnd),IDC_LIST1,WM_SETFONT,GetStockObject(font),0);
				reset_line_width();
				InvalidateRect(GetDlgItem(GetParent(hwnd),IDC_LIST1),NULL,TRUE);
			}
			break;
		case IDC_OPEN_INI:
			open_ini(hwnd,GetKeyState(VK_CONTROL)&0x8000);
			break;
		case IDC_APPLY:
			save_options(hwnd);
			break;
		case IDOK:
			save_options(hwnd);
			EndDialog(hwnd,TRUE);
			return 0;
		case IDCANCEL:
			save_select_open(hwnd);
			EndDialog(hwnd,0);
			return 0;
		}
		break;
	}
	return 0;
}