Changeset 29501


Ignore:
Timestamp:
07/19/14 15:29:47 (9 years ago)
Author:
tobayer
Message:

[sudoku plugin] add config menu and help

Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • titan/plugins/sudoku/sudoku.c

    r29470 r29501  
    5353                tmpstr = ostrcat(g_SudokuCorePath, " --create-easy >/tmp/.sudoku_puzzle", 0, 0);
    5454        }
    55         debug(10, "(%s)",tmpstr);
     55        //debug(10, "(%s)",tmpstr);
    5656        system(tmpstr);
    5757        free(tmpstr); tmpstr = NULL;
    5858
    5959        tmpstr = ostrcat(g_SudokuCorePath, " </tmp/.sudoku_puzzle >/tmp/.sudoku_solved", 0, 0);
    60         debug(10, "%s",tmpstr);
     60        //debug(10, "%s",tmpstr);
    6161        system(tmpstr);
    6262        free(tmpstr); tmpstr = NULL;
     
    150150}
    151151
     152void screensudoku_settings() {
     153        int rcret = 0;
     154        struct skin* sudoku_settings = getscreen("sudoku_settings");
     155        struct skin* set_listbox = getscreennode(sudoku_settings, "listbox");
     156        struct skin* set_posx = getscreennode(sudoku_settings, "posx");
     157        struct skin* tmp = NULL;
     158
     159        struct clist *myconfig[LISTHASHSIZE] = {NULL};
     160        char* sudokucfg = NULL;
     161
     162        sudokucfg = createpluginpath("/sudoku/sudoku.cfg", 0);
     163        readconfig(sudokucfg, myconfig);
     164        //debug(10, "config: (%s)", sudokucfg);
     165        //debug(10, "config: (%s)", getlist(myconfig, "xpos", NULL));
     166
     167        addchoicebox(set_posx, "left", _("left"));
     168        addchoicebox(set_posx, "center", _("center"));
     169        addchoicebox(set_posx, "right", _("right"));
     170        setchoiceboxselection(set_posx, getlist(myconfig, "xpos", NULL));
     171
     172        if ( ostrcmp(getlist(myconfig, "xpos", NULL), "right")  == 0 ) {
     173                sudoku_settings->posx = RIGHT;
     174        } else if ( ostrcmp(getlist(myconfig, "xpos", NULL), "center")  == 0 ) {
     175                sudoku_settings->posx = CENTER;
     176        } else {
     177                sudoku_settings->posx = LEFT;
     178        }
     179
     180        drawscreen(sudoku_settings, 0, 0);
     181        addscreenrc(sudoku_settings, set_listbox);
     182
     183        tmp = set_listbox->select;
     184        while(1) {
     185                addscreenrc(sudoku_settings, tmp);
     186                rcret = waitrc(sudoku_settings, 0, 0);
     187                tmp = set_listbox->select;
     188
     189                if ( rcret == getrcconfigint("rcexit", NULL) || rcret == getrcconfigint("rcmenu", NULL) ) break;
     190
     191                if (rcret == getrcconfigint("rcok", NULL) ) {
     192                        //debug(10, "posx new: (%s)", set_posx->ret);
     193                        addlist(myconfig, "xpos", set_posx->ret);
     194                        writelist(myconfig, sudokucfg);
     195                        break;
     196                }
     197        }
     198
     199        freelist(myconfig);
     200        free(sudokucfg); sudokucfg = NULL;
     201
     202        delownerrc(sudoku_settings);
     203        clearscreen(sudoku_settings);
     204}
     205
     206void screensudoku_help() {
     207        int rcret = 0;
     208        struct skin* sudoku_help = getscreen("sudoku_help");
     209
     210        struct clist *myconfig[LISTHASHSIZE] = {NULL};
     211        char* sudokucfg = NULL;
     212
     213        sudokucfg = createpluginpath("/sudoku/sudoku.cfg", 0);
     214        readconfig(sudokucfg, myconfig);
     215
     216        if ( ostrcmp(getlist(myconfig, "xpos", NULL), "right")  == 0 ) {
     217                sudoku_help->posx = RIGHT;
     218        } else if ( ostrcmp(getlist(myconfig, "xpos", NULL), "center")  == 0 ) {
     219                sudoku_help->posx = CENTER;
     220        } else {
     221                sudoku_help->posx = LEFT;
     222        }
     223
     224        freelist(myconfig);
     225        free(sudokucfg); sudokucfg = NULL;
     226
     227        drawscreen(sudoku_help, 0, 0);
     228
     229        while(1) {
     230                rcret = waitrc(sudoku_help, 0, 0);
     231                if ( rcret == getrcconfigint("rcexit", NULL) || rcret == getrcconfigint("rchelp", NULL) ) break;
     232        }
     233
     234        delownerrc(sudoku_help);
     235        clearscreen(sudoku_help);
     236}
     237
    152238void screensudoku() {
    153239        int rcret = 0, iLevel = 0;
     
    158244        struct skin* wait = getscreen("wait");
    159245
     246
     247        struct clist *myconfig[LISTHASHSIZE] = {NULL};
     248        char* sudokucfg = NULL;
     249
     250        sudokucfg = createpluginpath("/sudoku/sudoku.cfg", 0);
     251        readconfig(sudokucfg, myconfig);
     252        //debug(10, "config: (%s)", sudokucfg);
     253        //debug(10, "config: (%s)", getlist(myconfig, "xpos", NULL));
     254
     255        if ( ostrcmp(getlist(myconfig, "xpos", NULL), "right")  == 0 ) {
     256                sudoku->posx = RIGHT;
     257                wait->posx = RIGHT;
     258        } else if ( ostrcmp(getlist(myconfig, "xpos", NULL), "center")  == 0 ) {
     259                sudoku->posx = CENTER;
     260                wait->posx = CENTER;
     261        } else {
     262                sudoku->posx = LEFT;
     263                wait->posx = LEFT;
     264        }
     265
     266        freelist(myconfig);
     267        free(sudokucfg); sudokucfg = NULL;
    160268
    161269        drawscreen(sudoku, 0, 0);
     
    170278        addscreenrc(sudoku, grid);
    171279
    172         while(1)
    173         {
     280        while(1) {
    174281                rcret = waitrc(sudoku, 0, 0);
     282
     283                if(rcret == getrcconfigint("rchelp", NULL)) {
     284                        screensudoku_help();
     285                        drawscreen(sudoku, 0, 0);
     286                        continue;
     287                }
     288
     289                if(rcret == getrcconfigint("rcmenu", NULL)) {
     290                        screensudoku_settings();
     291
     292                        sudokucfg = createpluginpath("/sudoku/sudoku.cfg", 0);
     293                        readconfig(sudokucfg, myconfig);
     294                        //debug(10, "config: (%s)", sudokucfg);
     295                        //debug(10, "config: (%s)", getlist(myconfig, "xpos", NULL));
     296
     297                        if ( ostrcmp(getlist(myconfig, "xpos", NULL), "right")  == 0 ) {
     298                                sudoku->posx = RIGHT;
     299                                wait->posx = RIGHT;
     300                        } else if ( ostrcmp(getlist(myconfig, "xpos", NULL), "center")  == 0 ) {
     301                                sudoku->posx = CENTER;
     302                                wait->posx = CENTER;
     303                        } else {
     304                                sudoku->posx = LEFT;
     305                                wait->posx = LEFT;
     306                        }
     307
     308                        freelist(myconfig);
     309                        free(sudokucfg); sudokucfg = NULL;
     310
     311                        drawscreen(sudoku, 0, 0);
     312                        continue;
     313                }
    175314
    176315                if(rcret == getrcconfigint("rcexit", NULL)) break;
     
    240379
    241380        pluginaktiv = 1;
    242         debug(10, "Sudoku Plugin loaded!");
     381        debug(10, "sudoku plugin loaded!");
    243382}
    244383
     
    247386        delmarkedscreen(208);
    248387        pluginaktiv = 0;
    249         debug(10, "Sudoku Plugin removed!");
     388        debug(10, "sudoku plugin removed!");
    250389}
    251390
     
    257396        screensudoku();
    258397
    259         //reset markcolor 
     398        //reset
    260399        status.listboxselectcol = tmplistboxselectcol;
    261400}
  • titan/skins/sudoku/skin.xml

    r29469 r29501  
    33
    44
    5 <screen name="wait" text="please wait..." fontsize="40" fontcol="fontcol" posx="30" posy="600" halign="center" width="562" height="40" bgcol="-2">
     5<screen name="wait" text="please wait..." fontsize="40" fontcol="fontcol" posx="0" posy="600" halign="center" width="622" height="40" bgcol="-2">
    66</screen>
    77
     
    1313##      <node style="dbg" name="box3" posx="0" posy="375" width="100%" height="190" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle">
    1414
    15         <node name="box11" posx="5"   posy="5"   width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle">
    16         <node name="box12" posx="195" posy="5"   width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="leftmiddle">
    17         <node name="box13" posx="385" posy="5"   width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle">
     15        <node name="box11" posx="5"   posy="5"   width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle" transparent="0">
     16        <node name="box12" posx="195" posy="5"   width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="leftmiddle" transparent="0">
     17        <node name="box13" posx="385" posy="5"   width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle" transparent="0">
    1818
    19         <node name="box21" posx="5"   posy="195" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle">
    20         <node name="box22" posx="195" posy="195" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="leftmiddle">
    21         <node name="box23" posx="385" posy="195" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle">
     19        <node name="box21" posx="5"   posy="195" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle" transparent="0">
     20        <node name="box22" posx="195" posy="195" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="leftmiddle" transparent="0">
     21        <node name="box23" posx="385" posy="195" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle" transparent="0">
    2222
    23         <node name="box31" posx="5"   posy="385" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle">
    24         <node name="box32" posx="195" posy="385" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="leftmiddle">
    25         <node name="box33" posx="385" posy="385" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle">
     23        <node name="box31" posx="5"   posy="385" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle" transparent="0">
     24        <node name="box32" posx="195" posy="385" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="leftmiddle" transparent="0">
     25        <node name="box33" posx="385" posy="385" width="170" height="170" bgcol="#267FB2" bgcol2="#78C5E6" gradient="topmiddle" transparent="0">
    2626
    2727
    2828
    29         <node type="grid" name="grid" fontcol="white" fontsize="40" posx="0" posy="0" width="562" height="632" scrollbar="no">
     29        <node type="grid" name="grid" fontcol="white" fontsize="40" posx="0" posy="0" width="562" height="632" scrollbar="no" transparent="0">
    3030                <node parent="grid" bgspace="5" bgcol="grey" posx="0"   posy="0"  width="60" height="60" halign="center" valign="middle" type="gridbr">
    3131                <node parent="grid" bgspace="5" bgcol="grey" posx="60"  posy="0"  width="60" height="60" halign="center" valign="middle">
     
    121121        <node name="checks" fontsize="30" fontcol="fontcol" posx="right" posy="580" width="250" height="30" halign="right" valign="middle">
    122122
    123 <node name="b1" text="OK"   fontsize="28" fontcol="white" posx="left"  posy="bottom" width="100" height="40" halign="center" valign="middle" bgcol="#BBBBBB">
    124 <node name="b2" text="EXIT" fontsize="28" fontcol="white" posx="right" posy="bottom" width="100" height="40" halign="center" valign="middle" bgcol="#BBBBBB">
    125 <node name="b3" text="Hard" fontsize="28" fontcol="white" posx="175"   posy="bottom" width="100" height="40" halign="center" valign="middle" bgcol="#B82120">
    126 <node name="b4" text="Easy" fontsize="28" fontcol="white" posx="285"   posy="bottom" width="100" height="40" halign="center" valign="middle" bgcol="#30BA30">
     123<node name="b1" text="OK"   fontsize="28" fontcol="white" posx="left"  posy="bottom" width="80"  height="40" halign="center" valign="middle" bgcol="#BBBBBB">
     124<node name="b2" text="EXIT" fontsize="28" fontcol="white" posx="right" posy="bottom" width="80"  height="40" halign="center" valign="middle" bgcol="#BBBBBB">
     125<node name="b3" text="Menu" fontsize="28" fontcol="white" posx="90"    posy="bottom" width="100" height="40" halign="center" valign="middle" bgcol="#BBBBBB">
     126<node name="b4" text="Hard" fontsize="28" fontcol="white" posx="200"   posy="bottom" width="100" height="40" halign="center" valign="middle" bgcol="#B82120">
     127<node name="b5" text="Easy" fontsize="28" fontcol="white" posx="310"   posy="bottom" width="100" height="40" halign="center" valign="middle" bgcol="#30BA30">
     128<node name="b6" text="?"    fontsize="28" fontcol="white" posx="420"   posy="bottom" width="52"  height="40" halign="center" valign="middle" bgcol="#BBBBBB">
    127129</screen>
     130
     131
     132<screen name="sudoku_settings" bgcol="#267FB2" posx="0" posy="0" width="622" height="100%" hspace="30" vspace="30" transparent="0">
     133        <node type="listbox" name="listbox" fontcol="white" fontsize="40" posx="0" posy="0" width="562" height="632" scrollbar="no">
     134                <node parent="listbox" name="posx" text="X-Position" type="choicebox" valign="middle" width="100%" height="35">
     135<node name="b1" text="OK"   fontsize="28" fontcol="white" posx="left"  posy="bottom" width="80" height="40" halign="center" valign="middle" bgcol="#BBBBBB">
     136<node name="b2" text="EXIT" fontsize="28" fontcol="white" posx="right" posy="bottom" width="80" height="40" halign="center" valign="middle" bgcol="#BBBBBB">
     137</screen>
     138
     139
     140<screen name="sudoku_help" bgcol="#267FB2" posx="0" posy="0" width="622" height="100%" hspace="30" vspace="30" transparent="0">
     141#       <node style="dbg" name="border" posx="0" posy="0" width="562" height="610">
     142        <node name="title" text="Sudoku Hilfe" fontsize="40" fontcol="fontcol" posx="0" posy="0" width="100%" height="40" halign="center" valign="middle">
     143
     144        <node name="text01" text="1..9" fontsize="28" fontcol="white" posx="0" posy="100" width="100" height="40" halign="center" valign="middle" bgcol="#BBBBBB">
     145        <node name="text11" text="Eingabe der Zahlen 1 bis 9" fontsize="28" fontcol="fontcol" posx="120" posy="105" width="442" height="30" halign="left" valign="middle">
     146
     147        <node name="text02" text="0" fontsize="28" fontcol="white" posx="0" posy="150" width="100" height="40" halign="center" valign="middle" bgcol="#BBBBBB">
     148        <node name="text12" text="Falsche Eingaben löschen" fontsize="28" fontcol="fontcol" posx="120" posy="155" width="442" height="30" halign="left" valign="middle">
     149
     150        <node name="text03" text="OK" fontsize="28" fontcol="white" posx="0" posy="200" width="100" height="40" halign="center" valign="middle" bgcol="#BBBBBB">
     151        <node name="text13" text="Eingaben überprüfen" fontsize="28" fontcol="fontcol" posx="120" posy="205" width="442" height="30" halign="left" valign="middle">
     152
     153        <node name="text04" text="Menu" fontsize="28" fontcol="white" posx="0" posy="250" width="100" height="40" halign="center" valign="middle" bgcol="#BBBBBB">
     154        <node name="text14" text="Einstellungsmenü öffnen" fontsize="28" fontcol="fontcol" posx="120" posy="255" width="442" height="30" halign="left" valign="middle">
     155
     156        <node name="text05" text="Hard" fontsize="28" fontcol="white" posx="0" posy="300" width="100" height="40" halign="center" valign="middle" bgcol="#B82120">
     157        <node name="text15" text="Neues Spiel (schwierig)" fontsize="28" fontcol="fontcol" posx="120" posy="305" width="442" height="30" halign="left" valign="middle">
     158
     159        <node name="text06" text="Easy" fontsize="28" fontcol="white" posx="0" posy="350" width="100" height="40" halign="center" valign="middle" bgcol="#30BA30">
     160        <node name="text16" text="Neues Spiel (leicht)" fontsize="28" fontcol="fontcol" posx="120" posy="355" width="442" height="30" halign="left" valign="middle">
     161
     162<node name="b1" text="EXIT" fontsize="28" fontcol="white" posx="right" posy="bottom" width="80" height="40" halign="center" valign="middle" bgcol="#BBBBBB">
     163</screen>
Note: See TracChangeset for help on using the changeset viewer.