Revision | 12 (tree) |
---|---|
Time | 2008-02-26 12:49:52 |
Author | ![]() |
NGメニューを有効に
@@ -29,6 +29,9 @@ | ||
29 | 29 | extern int running; //main.c |
30 | 30 | extern char cwDir[256]; //main.c |
31 | 31 | extern void* framebuffer; // pg.c |
32 | +extern unsigned long pgCursorX, pgCursorY; // pg.c | |
33 | +extern unsigned int list[512*512]; // pg.c | |
34 | +extern intraFont* jpn0; // pg.c | |
32 | 35 | |
33 | 36 | int tateFlag = 0; |
34 | 37 | int sel = 0; |
@@ -35,6 +38,7 @@ | ||
35 | 38 | const char* userAgent = "Monazilla/1.00 (Compatible; PSP; ja) owata\(^o^)/0.4.3"; |
36 | 39 | const char* logDir = "log"; |
37 | 40 | char cookie[128] = {0}; |
41 | +char keyWords[128]; | |
38 | 42 | SceCtrlData pad; |
39 | 43 | SceCtrlData oldPad; |
40 | 44 | MESSAGE_HELPER mh; |
@@ -1162,3 +1166,55 @@ | ||
1162 | 1166 | } |
1163 | 1167 | s[i] = '\0'; |
1164 | 1168 | } |
1169 | + | |
1170 | +/**************** | |
1171 | +入力ダイアログ表示 | |
1172 | +text1: ダイアログに表示されるタイトル | |
1173 | +text2: OSKに表示するタイトル | |
1174 | +戻り値 0=入力, -1=取消し | |
1175 | +*****************/ | |
1176 | +int psp2chInputDialog(const unsigned short* text1, char* text2) | |
1177 | +{ | |
1178 | + keyWords[0] = '\0'; | |
1179 | + while (running) | |
1180 | + { | |
1181 | + if(sceCtrlPeekBufferPositive(&pad, 1)) | |
1182 | + { | |
1183 | + if (pad.Buttons != oldPad.Buttons) | |
1184 | + { | |
1185 | + oldPad = pad; | |
1186 | + if(pad.Buttons & PSP_CTRL_CIRCLE) | |
1187 | + { | |
1188 | + psp2chGets(text2, keyWords, 128, 1); | |
1189 | + } | |
1190 | + if(pad.Buttons & PSP_CTRL_CROSS) | |
1191 | + { | |
1192 | + return -1; | |
1193 | + } | |
1194 | + if(pad.Buttons & PSP_CTRL_SQUARE) | |
1195 | + { | |
1196 | + break; | |
1197 | + } | |
1198 | + } | |
1199 | + sceGuStart(GU_DIRECT, list); | |
1200 | + sceGuClearDepth(0); | |
1201 | + sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); | |
1202 | + pgFillvram(BLUE, 80, 60, 320, 45); | |
1203 | + pgEditBox(WHITE, 140, 85, 340, 100); | |
1204 | + pgCursorX = 142; | |
1205 | + pgCursorY = 87; | |
1206 | + pgPrint(keyWords, BLACK, WHITE, 340); | |
1207 | + pgCopy(0, 0); | |
1208 | + pgMenuBar(" ○ : 入力 × : 戻る □ : 決定"); | |
1209 | + pgCursorX = 240; | |
1210 | + pgCursorY = 77; | |
1211 | + intraFontSetStyle(jpn0, 1.0f, YELLOW, 0, INTRAFONT_ALIGN_CENTER); | |
1212 | + intraFontPrintUCS2(jpn0, pgCursorX, pgCursorY, text1); | |
1213 | + sceGuFinish(); | |
1214 | + sceGuSync(0,0); | |
1215 | + } | |
1216 | + sceDisplayWaitVblankStart(); | |
1217 | + framebuffer = sceGuSwapBuffers(); | |
1218 | + } | |
1219 | + return 0; | |
1220 | +} |
@@ -124,5 +124,6 @@ | ||
124 | 124 | int psp2chGetHttpHeaders(int mySocket, HTTP_HEADERS* header); |
125 | 125 | int psp2chApConnect(void); |
126 | 126 | void psp2chGets(char* title, char* text, int num, int lines); |
127 | +int psp2chInputDialog(const unsigned short* text1, char* text2); | |
127 | 128 | |
128 | 129 | #endif |
@@ -40,6 +40,8 @@ | ||
40 | 40 | extern S_2CH_HEADER_COLOR resHeaderColor; // psp2ch.c |
41 | 41 | extern S_2CH_RES_COLOR resColor; // psp2ch.c |
42 | 42 | extern S_2CH_BAR_COLOR resBarColor; // psp2ch.c |
43 | +extern const char* ngNameFile; | |
44 | +extern const char* ngIDFile; | |
43 | 45 | |
44 | 46 | int preLine = -2; |
45 | 47 | char* resBuffer = NULL; |
@@ -134,6 +136,12 @@ | ||
134 | 136 | else if(pad.Buttons & PSP_CTRL_START) |
135 | 137 | { |
136 | 138 | psp2chMenu(0, res.start*LINE_PITCH); |
139 | + totalLine = psp2chResSetLine(&bar); | |
140 | + if (res.start > totalLine - lineEnd) | |
141 | + { | |
142 | + res.start = totalLine - lineEnd; | |
143 | + } | |
144 | + preLine = -2; | |
137 | 145 | } |
138 | 146 | // ○ボタン |
139 | 147 | else if(pad.Buttons & PSP_CTRL_CIRCLE) |
@@ -312,26 +320,40 @@ | ||
312 | 320 | } |
313 | 321 | else |
314 | 322 | { |
315 | - memset(&mh,0,sizeof(MESSAGE_HELPER)); | |
316 | - mh.options = PSP_UTILITY_MSGDIALOG_OPTION_TEXT | | |
317 | - PSP_UTILITY_MSGDIALOG_OPTION_YESNO_BUTTONS | PSP_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO; | |
318 | - strcpy(mh.message, TEXT_5); | |
319 | - pspShowMessageDialog(&mh, DIALOG_LANGUAGE_AUTO); | |
320 | - sceCtrlPeekBufferPositive(&oldPad, 1); | |
321 | - if (mh.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_YES) | |
323 | + if (idMenu >= 0) | |
322 | 324 | { |
323 | - sprintf(path, "%s/%s/%s/%d.dat", cwDir, logDir, title, dat); | |
324 | - sceIoRemove(path); | |
325 | - sprintf(path, "%s/%s/%s/%d.idx", cwDir, logDir, title, dat); | |
326 | - sceIoRemove(path); | |
327 | - if (threadList) | |
325 | + psp2chNGAdd(ngIDFile, idAnchor[idMenu].id); | |
326 | + psp2chResCheckNG(); | |
327 | + totalLine = psp2chResSetLine(&bar); | |
328 | + if (res.start > totalLine - lineEnd) | |
328 | 329 | { |
329 | - threadList[threadSort[thread.select]].old = 0; | |
330 | - psp2chSort(-1); | |
330 | + res.start = totalLine - lineEnd; | |
331 | 331 | } |
332 | - sel = ret; | |
333 | - return 0; | |
332 | + preLine = -2; | |
334 | 333 | } |
334 | + else | |
335 | + { | |
336 | + memset(&mh,0,sizeof(MESSAGE_HELPER)); | |
337 | + mh.options = PSP_UTILITY_MSGDIALOG_OPTION_TEXT | | |
338 | + PSP_UTILITY_MSGDIALOG_OPTION_YESNO_BUTTONS | PSP_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO; | |
339 | + strcpy(mh.message, TEXT_5); | |
340 | + pspShowMessageDialog(&mh, DIALOG_LANGUAGE_AUTO); | |
341 | + sceCtrlPeekBufferPositive(&oldPad, 1); | |
342 | + if (mh.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_YES) | |
343 | + { | |
344 | + sprintf(path, "%s/%s/%s/%d.dat", cwDir, logDir, title, dat); | |
345 | + sceIoRemove(path); | |
346 | + sprintf(path, "%s/%s/%s/%d.idx", cwDir, logDir, title, dat); | |
347 | + sceIoRemove(path); | |
348 | + if (threadList) | |
349 | + { | |
350 | + threadList[threadSort[thread.select]].old = 0; | |
351 | + psp2chSort(-1); | |
352 | + } | |
353 | + sel = ret; | |
354 | + return 0; | |
355 | + } | |
356 | + } | |
335 | 357 | } |
336 | 358 | } |
337 | 359 | } |
@@ -388,7 +410,7 @@ | ||
388 | 410 | } |
389 | 411 | else if (idMenu >= 0) |
390 | 412 | { |
391 | - menuStr = " ○ : ID抽出 "; | |
413 | + menuStr = " ○ : ID抽出 □ : NGID登録"; | |
392 | 414 | } |
393 | 415 | else if (rMenu) |
394 | 416 | { |
@@ -570,8 +592,11 @@ | ||
570 | 592 | for (i = 0, j = 0; i < res.count; i++) |
571 | 593 | { |
572 | 594 | resList[i].line = psp2chCountRes(i, RES_SCR_WIDTH_V); |
573 | - j += resList[i].line; | |
574 | - j++; | |
595 | + if (resList[i].ng == 0) | |
596 | + { | |
597 | + j += resList[i].line; | |
598 | + j++; | |
599 | + } | |
575 | 600 | } |
576 | 601 | } |
577 | 602 | else |
@@ -584,8 +609,11 @@ | ||
584 | 609 | for (i = 0, j = 0; i < res.count; i++) |
585 | 610 | { |
586 | 611 | resList[i].line = psp2chCountRes(i, RES_SCR_WIDTH); |
587 | - j += resList[i].line; | |
588 | - j++; | |
612 | + if (resList[i].ng == 0) | |
613 | + { | |
614 | + j += resList[i].line; | |
615 | + j++; | |
616 | + } | |
589 | 617 | } |
590 | 618 | } |
591 | 619 | bar->total = j * LINE_PITCH; |
@@ -727,6 +755,72 @@ | ||
727 | 755 | } |
728 | 756 | |
729 | 757 | /***************************** |
758 | +NGチェック | |
759 | +*****************************/ | |
760 | +void psp2chResCheckNG(void) | |
761 | +{ | |
762 | + char* buf, *p, *q; | |
763 | + int i; | |
764 | + | |
765 | + if (resList == NULL) | |
766 | + { | |
767 | + return; | |
768 | + } | |
769 | + for (i = 0; i < res.count; i++) | |
770 | + { | |
771 | + resList[i].ng = 0; | |
772 | + } | |
773 | + buf = NULL; | |
774 | + buf = psp2chGetNGBuf(ngNameFile, buf); | |
775 | + if (buf) | |
776 | + { | |
777 | + p= buf; | |
778 | + while (*p) | |
779 | + { | |
780 | + q = strchr(p, '\n'); | |
781 | + if (q == NULL) | |
782 | + { | |
783 | + break; | |
784 | + } | |
785 | + *q = '\0'; | |
786 | + for (i = 0; i < res.count; i++) | |
787 | + { | |
788 | + if (strstr(resList[i].name, p)) | |
789 | + { | |
790 | + resList[i].ng = 1; | |
791 | + } | |
792 | + } | |
793 | + p = q + 1; | |
794 | + } | |
795 | + free(buf); | |
796 | + } | |
797 | + buf = NULL; | |
798 | + buf = psp2chGetNGBuf(ngIDFile, buf); | |
799 | + if (buf) | |
800 | + { | |
801 | + p= buf; | |
802 | + while (*p) | |
803 | + { | |
804 | + q = strchr(p, '\n'); | |
805 | + if (q == NULL) | |
806 | + { | |
807 | + break; | |
808 | + } | |
809 | + *q = '\0'; | |
810 | + for (i = 0; i < res.count; i++) | |
811 | + { | |
812 | + if (strcmp(resList[i].id, p) == 0) | |
813 | + { | |
814 | + resList[i].ng = 1; | |
815 | + } | |
816 | + } | |
817 | + p = q + 1; | |
818 | + } | |
819 | + free(buf); | |
820 | + } | |
821 | +} | |
822 | + | |
823 | +/***************************** | |
730 | 824 | datファイルをメモリに読み込みデータの区切りを'\0'(文字列終端)に書き換える |
731 | 825 | resList構造体のポインタに各データのアドレスを代入 |
732 | 826 | *****************************/ |
@@ -935,8 +1029,8 @@ | ||
935 | 1029 | p++; |
936 | 1030 | buf = p; |
937 | 1031 | resList[ret].num = ret; |
938 | - resList[ret].ng = 0; | |
939 | 1032 | } |
1033 | + psp2chResCheckNG(); | |
940 | 1034 | psp2chSaveIdx(title, dat); |
941 | 1035 | return 0; |
942 | 1036 | } |
@@ -1582,6 +1676,16 @@ | ||
1582 | 1676 | pgCursorY = (LINE_PITCH*drawLine)&0x01FF; |
1583 | 1677 | resAnchorCount = 0; |
1584 | 1678 | resAnchor[0].x1 = 0; |
1679 | + for (i = 0; i < 50; i++) | |
1680 | + { | |
1681 | + urlAnchor[i].x1 = 0; | |
1682 | + urlAnchor[i].x2 = 0; | |
1683 | + } | |
1684 | + for (i = 0; i < 40; i++) | |
1685 | + { | |
1686 | + idAnchor[i].x1 = 0; | |
1687 | + idAnchor[i].x2 = 0; | |
1688 | + } | |
1585 | 1689 | line = 0; |
1586 | 1690 | while (line <= lineEnd) |
1587 | 1691 | { |
@@ -59,6 +59,7 @@ | ||
59 | 59 | int psp2chResCursorMove(int* totalLine, int* lineEnd, int* cursorY, int limitY); |
60 | 60 | int psp2chResSetLine(S_SCROLLBAR* bar); |
61 | 61 | void psp2chResPadMove(int* cursorX, int* cursorY, int limitX, int limitY); |
62 | +void psp2chResCheckNG(void); | |
62 | 63 | int psp2chResList(char* host, char* dir, char* title, int dat); |
63 | 64 | int psp2chGetDat(char* host, char* dir, char* title, int dat); |
64 | 65 | void psp2chSaveIdx(char* title, int dat); |
@@ -391,7 +391,7 @@ | ||
391 | 391 | if (tateFlag) |
392 | 392 | { |
393 | 393 | tmp = x1; |
394 | - x1 = SCR_WIDTH - y2; | |
394 | + x1 = SCR_WIDTH - y2 + 1; | |
395 | 395 | y2 = x2; |
396 | 396 | x2 = SCR_WIDTH - y1; |
397 | 397 | y1 = tmp; |
@@ -4,6 +4,7 @@ | ||
4 | 4 | |
5 | 5 | #include "pspdialogs.h" |
6 | 6 | #include <stdio.h> |
7 | +#include <malloc.h> | |
7 | 8 | #include <pspdebug.h> |
8 | 9 | #include <pspctrl.h> |
9 | 10 | #include "pg.h" |
@@ -23,19 +24,24 @@ | ||
23 | 24 | extern SceCtrlData oldPad; // psp2ch.c |
24 | 25 | extern MESSAGE_HELPER mh; // psp2ch.c |
25 | 26 | extern S_2CH_TXT_COLOR menuWinColor; // psp2ch.c |
27 | +extern char keyWords[128]; //psp2ch.c | |
28 | +extern S_2CH_RES* resList; | |
29 | +extern S_2CH_SCREEN res; | |
26 | 30 | |
27 | -#define MENU_WIDTH (80) | |
28 | -#define MENU_HEIGHT (52) | |
29 | -#define MENU_ITEM (4) | |
31 | +const char* ngNameFile = "ngname.txt"; | |
32 | +const char* ngIDFile = "ngid.txt"; | |
30 | 33 | |
31 | 34 | /**************** |
32 | 35 | メニュー選択ウィンドウ |
33 | 36 | ****************/ |
37 | +#define MENU_WIDTH (80) | |
38 | +#define MENU_HEIGHT (52) | |
39 | +#define MENU_ITEM (4) | |
34 | 40 | int psp2chMenu(int pixelsX, int pixelsY) |
35 | 41 | { |
42 | + const char* menuList[] = {"NG設定"}; | |
36 | 43 | static char* menuStr = ""; |
37 | 44 | int lineEnd; |
38 | - const char* menuList[] = {"基本設定", "NG設定"}; | |
39 | 45 | static S_2CH_SCREEN menu; |
40 | 46 | int startX, startY, scrX, scrY; |
41 | 47 |
@@ -45,13 +51,13 @@ | ||
45 | 51 | startY = (SCR_WIDTH - MENU_HEIGHT) / 2; } |
46 | 52 | else |
47 | 53 | { |
48 | - startX = (SCR_WIDTH - 100) / 2; | |
54 | + startX = (SCR_WIDTH - MENU_WIDTH) / 2; | |
49 | 55 | startY = (SCR_HEIGHT - MENU_HEIGHT) / 2; |
50 | 56 | } |
51 | - scrX = 100; | |
57 | + scrX = MENU_WIDTH; | |
52 | 58 | scrY = MENU_HEIGHT; |
53 | 59 | lineEnd = MENU_ITEM; |
54 | - menu.count = 2; | |
60 | + menu.count = 1; | |
55 | 61 | printBuf = winPixels; |
56 | 62 | while (running) |
57 | 63 | { |
@@ -66,11 +72,16 @@ | ||
66 | 72 | switch (menu.select) |
67 | 73 | { |
68 | 74 | case 0: |
75 | + psp2chMenuNG(pixelsX, pixelsY); | |
69 | 76 | break; |
70 | 77 | case 1: |
71 | - psp2chMenuNG(pixelsX, pixelsY); | |
72 | 78 | break; |
73 | 79 | } |
80 | + printBuf = pixels; | |
81 | + pgCopy(pixelsX, pixelsY); | |
82 | + framebuffer = sceGuSwapBuffers(); | |
83 | + pgCopy(pixelsX, pixelsY); | |
84 | + printBuf = winPixels; | |
74 | 85 | } |
75 | 86 | else if(pad.Buttons & PSP_CTRL_CROSS) |
76 | 87 | { |
@@ -96,26 +107,34 @@ | ||
96 | 107 | return 0; |
97 | 108 | } |
98 | 109 | |
110 | +/**************** | |
111 | +NG設定ウィンドウ | |
112 | +****************/ | |
113 | +#define MENU_NG_WIDTH (80) | |
114 | +#define MENU_NG_HEIGHT (52) | |
115 | +#define MENU_NG_ITEM (4) | |
99 | 116 | void psp2chMenuNG(int pixelsX, int pixelsY) |
100 | 117 | { |
118 | + const unsigned short text1[] = {0x004E,0x0047,0x767B,0x9332,0x3059,0x308B,0x540D,0x524D,0x3092,0x5165,0x529B,0x3057,0x3066,0x304F,0x3060,0x3055,0x3044,0}; | |
119 | + char* text2 = "NGネーム"; | |
120 | + const char* menuList[] = {"NG名前登録", "NG名前削除", "NGID削除"}; | |
101 | 121 | static char* menuStr = ""; |
102 | 122 | int lineEnd; |
103 | - const char* menuList[] = {"NG名前登録", "NG名前削除", "NGID削除"}; | |
104 | 123 | static S_2CH_SCREEN menu; |
105 | 124 | int startX, startY, scrX, scrY; |
106 | 125 | |
107 | 126 | if (tateFlag) |
108 | 127 | { |
109 | - startX = (SCR_HEIGHT - MENU_WIDTH) / 2; | |
110 | - startY = (SCR_WIDTH - MENU_HEIGHT) / 2; } | |
128 | + startX = (SCR_HEIGHT - MENU_NG_WIDTH) / 2; | |
129 | + startY = (SCR_WIDTH - MENU_NG_HEIGHT) / 2; } | |
111 | 130 | else |
112 | 131 | { |
113 | - startX = (SCR_WIDTH - MENU_WIDTH) / 2; | |
114 | - startY = (SCR_HEIGHT - MENU_HEIGHT) / 2; | |
132 | + startX = (SCR_WIDTH - MENU_NG_WIDTH) / 2; | |
133 | + startY = (SCR_HEIGHT - MENU_NG_HEIGHT) / 2; | |
115 | 134 | } |
116 | - scrX = MENU_WIDTH; | |
117 | - scrY = MENU_HEIGHT; | |
118 | - lineEnd = MENU_ITEM; | |
135 | + scrX = MENU_NG_WIDTH; | |
136 | + scrY = MENU_NG_HEIGHT; | |
137 | + lineEnd = MENU_NG_ITEM; | |
119 | 138 | menu.count = 3; |
120 | 139 | printBuf = pixels; |
121 | 140 | pgCopy(pixelsX, pixelsY); |
@@ -135,12 +154,26 @@ | ||
135 | 154 | switch (menu.select) |
136 | 155 | { |
137 | 156 | case 0: // NG name add |
157 | + pgFillvram(menuWinColor.bg, 0, 0, BUF_WIDTH, BUF_HEIGHT); | |
158 | + pgCopy(0,0); | |
159 | + framebuffer = sceGuSwapBuffers(); | |
160 | + if (psp2chInputDialog(text1, text2) == 0 && keyWords[0]) | |
161 | + { | |
162 | + psp2chNGAdd(ngNameFile, keyWords); | |
163 | + } | |
138 | 164 | break; |
139 | 165 | case 1: // NG name del |
166 | + psp2chNGDel(ngNameFile, pixelsX, pixelsY); | |
140 | 167 | break; |
141 | 168 | case 2: // NG ID del |
169 | + psp2chNGDel(ngIDFile, pixelsX, pixelsY); | |
142 | 170 | break; |
143 | 171 | } |
172 | + printBuf = pixels; | |
173 | + pgCopy(pixelsX, pixelsY); | |
174 | + framebuffer = sceGuSwapBuffers(); | |
175 | + pgCopy(pixelsX, pixelsY); | |
176 | + printBuf = winPixels; | |
144 | 177 | } |
145 | 178 | else if(pad.Buttons & PSP_CTRL_CROSS) |
146 | 179 | { |
@@ -158,15 +191,231 @@ | ||
158 | 191 | } |
159 | 192 | } |
160 | 193 | |
194 | +/**************** | |
195 | +NGファイルがあればバッファを確保し読み込んで返す | |
196 | +****************/ | |
197 | +char* psp2chGetNGBuf(const char* file, char* buf) | |
198 | +{ | |
199 | + SceUID fd; | |
200 | + SceIoStat st; | |
201 | + char path[256]; | |
202 | + int ret; | |
203 | + | |
204 | + sprintf(path, "%s/%s/%s", cwDir, logDir, file); | |
205 | + ret = sceIoGetstat(path, &st); | |
206 | + if (ret < 0) | |
207 | + { | |
208 | + return NULL; | |
209 | + } | |
210 | + buf = (char*)malloc(st.st_size + 1); | |
211 | + if (buf == NULL) | |
212 | + { | |
213 | + memset(&mh,0,sizeof(MESSAGE_HELPER)); | |
214 | + strcpy(mh.message, "memorry error\npsp2chNGDel() buf"); | |
215 | + pspShowMessageDialog(&mh, DIALOG_LANGUAGE_AUTO); | |
216 | + sceCtrlPeekBufferPositive(&oldPad, 1); | |
217 | + return NULL; | |
218 | + } | |
219 | + fd = sceIoOpen(path, PSP_O_RDONLY, 0777); | |
220 | + if (fd < 0) | |
221 | + { | |
222 | + free(buf); | |
223 | + memset(&mh,0,sizeof(MESSAGE_HELPER)); | |
224 | + sprintf(mh.message, "NG File open error\n%s", path); | |
225 | + pspShowMessageDialog(&mh, DIALOG_LANGUAGE_AUTO); | |
226 | + sceCtrlPeekBufferPositive(&oldPad, 1); | |
227 | + return NULL; | |
228 | + } | |
229 | + sceIoRead(fd, buf, st.st_size); | |
230 | + sceIoClose(fd); | |
231 | + buf[st.st_size] = '\0'; | |
232 | + return buf; | |
233 | +} | |
234 | + | |
235 | +/**************** | |
236 | +NG削除 | |
237 | +****************/ | |
238 | +#define MENU_NGLIST_WIDTH (200) | |
239 | +int psp2chNGDel(const char* file, int pixelsX, int pixelsY) | |
240 | +{ | |
241 | + SceUID fd; | |
242 | + char path[256]; | |
243 | + char *buf, *p, *q, *menuStr; | |
244 | + char** list; | |
245 | + int i, lineEnd; | |
246 | + static S_2CH_SCREEN menu; | |
247 | + int startX, startY, scrX, scrY; | |
248 | + | |
249 | + if (tateFlag) | |
250 | + { | |
251 | + startX = (SCR_HEIGHT - MENU_NGLIST_WIDTH) / 2; | |
252 | + startY = (SCR_WIDTH - 400) / 2; | |
253 | + scrY = 390; | |
254 | + lineEnd = 30; | |
255 | + } | |
256 | + else | |
257 | + { | |
258 | + startX = (SCR_WIDTH - MENU_NGLIST_WIDTH) / 2; | |
259 | + startY = (SCR_HEIGHT - 200) / 2; | |
260 | + scrY = 195; | |
261 | + lineEnd = 15; | |
262 | + } | |
263 | + scrX = MENU_NGLIST_WIDTH; | |
264 | + printBuf = pixels; | |
265 | + pgCopy(pixelsX, pixelsY); | |
266 | + framebuffer = sceGuSwapBuffers(); | |
267 | + pgCopy(pixelsX, pixelsY); | |
268 | + printBuf = winPixels; | |
269 | + buf = NULL; | |
270 | + buf = psp2chGetNGBuf(file, buf); | |
271 | + if (buf == NULL) | |
272 | + { | |
273 | + return -1; | |
274 | + } | |
275 | + p= buf; | |
276 | + menu.count = 0; | |
277 | + while (*p) | |
278 | + { | |
279 | + if (*p++ == '\n') | |
280 | + { | |
281 | + menu.count++; | |
282 | + } | |
283 | + } | |
284 | + list = (char**)malloc(sizeof(char*) * menu.count); | |
285 | + if (list == NULL) | |
286 | + { | |
287 | + free(buf); | |
288 | + memset(&mh,0,sizeof(MESSAGE_HELPER)); | |
289 | + sprintf(mh.message, "memorry error\npsp2chNGDel() list"); | |
290 | + pspShowMessageDialog(&mh, DIALOG_LANGUAGE_AUTO); | |
291 | + sceCtrlPeekBufferPositive(&oldPad, 1); | |
292 | + return -1; | |
293 | + } | |
294 | + p = buf; | |
295 | + for (i = 0; i < menu.count; i++) | |
296 | + { | |
297 | + q = strchr(p, '\n'); | |
298 | + if (q == NULL) | |
299 | + { | |
300 | + break; | |
301 | + } | |
302 | + *q = '\0'; | |
303 | + list[i] = p; | |
304 | + p = q + 1; | |
305 | + } | |
306 | + sprintf(path, "%s/%s/%s", cwDir, logDir, file); | |
307 | + while (running) | |
308 | + { | |
309 | + if(sceCtrlPeekBufferPositive(&pad, 1)) | |
310 | + { | |
311 | + psp2chCursorSet(&menu, lineEnd); | |
312 | + if (pad.Buttons != oldPad.Buttons) | |
313 | + { | |
314 | + oldPad = pad; | |
315 | + if(pad.Buttons & PSP_CTRL_CIRCLE) | |
316 | + { | |
317 | + fd = sceIoOpen(path, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777); | |
318 | + if (fd < 0) | |
319 | + { | |
320 | + free(list); | |
321 | + free(buf); | |
322 | + memset(&mh,0,sizeof(MESSAGE_HELPER)); | |
323 | + sprintf(mh.message, "NG File open error\n%s", path); | |
324 | + pspShowMessageDialog(&mh, DIALOG_LANGUAGE_AUTO); | |
325 | + sceCtrlPeekBufferPositive(&oldPad, 1); | |
326 | + return -1; | |
327 | + } | |
328 | + for (i = 0; i < menu.count; i++) | |
329 | + { | |
330 | + sceIoWrite(fd, list[i], strlen(list[i])); | |
331 | + sceIoWrite(fd, "\n", 1); | |
332 | + } | |
333 | + sceIoClose(fd); | |
334 | + psp2chResCheckNG(); | |
335 | + break; | |
336 | + } | |
337 | + else if(pad.Buttons & PSP_CTRL_CROSS) | |
338 | + { | |
339 | + break; | |
340 | + } | |
341 | + else if(pad.Buttons & PSP_CTRL_SQUARE) | |
342 | + { | |
343 | + menu.count--; | |
344 | + for (i = menu.select; i < menu.count; i++) | |
345 | + { | |
346 | + list[i] = list[i + 1]; | |
347 | + } | |
348 | + } | |
349 | + } | |
350 | + menuStr = " ○ : 保存 × : 取消し □ : 削除"; | |
351 | + psp2chDrawMenu(list, menu, startX, startY, scrX, scrY); | |
352 | + pgCopyWindow(0, startX, startY, scrX, scrY); | |
353 | + pgWindowFrame(startX, startY, startX + scrX, startY + scrY); | |
354 | + pgMenuBar(menuStr); | |
355 | + sceDisplayWaitVblankStart(); | |
356 | + framebuffer = sceGuSwapBuffers(); | |
357 | + } | |
358 | + } | |
359 | + free(list); | |
360 | + free(buf); | |
361 | + return 0; | |
362 | +} | |
363 | + | |
364 | +/**************** | |
365 | +NG登録 | |
366 | +****************/ | |
367 | +int psp2chNGAdd(const char* file, char* val) | |
368 | +{ | |
369 | + SceUID fd; | |
370 | + char path[256]; | |
371 | + | |
372 | + sprintf(path, "%s/%s/%s", cwDir, logDir, file); | |
373 | + fd = sceIoOpen(path, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND, 0777); | |
374 | + if (fd < 0) | |
375 | + { | |
376 | + memset(&mh,0,sizeof(MESSAGE_HELPER)); | |
377 | + sprintf(mh.message, "NG File open error\n%s", path); | |
378 | + pspShowMessageDialog(&mh, DIALOG_LANGUAGE_AUTO); | |
379 | + sceCtrlPeekBufferPositive(&oldPad, 1); | |
380 | + return -1; | |
381 | + } | |
382 | + sceIoWrite(fd, val, strlen(val)); | |
383 | + sceIoWrite(fd, "\n", 1); | |
384 | + sceIoClose(fd); | |
385 | + pgMenuBar("登録しました"); | |
386 | + sceDisplayWaitVblankStart(); | |
387 | + framebuffer = sceGuSwapBuffers(); | |
388 | + pgWaitVn(60); | |
389 | + psp2chResCheckNG(); | |
390 | + return 0; | |
391 | +} | |
392 | + | |
393 | +/**************** | |
394 | +メニューウィンドウ描画 | |
395 | +****************/ | |
161 | 396 | void psp2chDrawMenu(char** menuList, S_2CH_SCREEN menu, int x, int y, int width, int height) |
162 | 397 | { |
163 | - int i; | |
398 | + int i, start, lineEnd; | |
164 | 399 | |
165 | 400 | pgCursorX = x; |
166 | 401 | pgCursorY = y; |
402 | + lineEnd = height / LINE_PITCH; | |
403 | + start = menu.start; | |
404 | + if (start + lineEnd > menu.count) | |
405 | + { | |
406 | + start = menu.count - lineEnd; | |
407 | + } | |
408 | + if (start < 0) | |
409 | + { | |
410 | + start = 0; | |
411 | + } | |
167 | 412 | pgFillvram(menuWinColor.bg, x, y, width, height); |
168 | - for (i = 0; i < menu.count; i++) | |
413 | + for (i = start; i < start + lineEnd; i++) | |
169 | 414 | { |
415 | + if (i >= menu.count) | |
416 | + { | |
417 | + return; | |
418 | + } | |
170 | 419 | if (i == menu.select) |
171 | 420 | { |
172 | 421 | pgFillvram(menuWinColor.s_bg, x, pgCursorY, width, LINE_PITCH); |
@@ -180,4 +429,3 @@ | ||
180 | 429 | pgCursorY += LINE_PITCH; |
181 | 430 | } |
182 | 431 | } |
183 | - |
@@ -36,11 +36,11 @@ | ||
36 | 36 | extern int preLine; // psp2chRes.c |
37 | 37 | extern S_2CH_THREAD_COLOR threadColor; // psp2ch.c |
38 | 38 | extern S_2CH_FAVORITE* findList; // psp2chSearch.c |
39 | +extern char keyWords[128]; //psp2ch.c | |
39 | 40 | |
40 | 41 | S_2CH_THREAD* threadList; |
41 | 42 | S_2CH_SCREEN thread; |
42 | 43 | int* threadSort = NULL; |
43 | -char keyWords[128]; | |
44 | 44 | |
45 | 45 | /**************** |
46 | 46 | スレッド一覧表示 |
@@ -671,48 +671,7 @@ | ||
671 | 671 | const unsigned short text1[] = {0x691C,0x7D22,0x6587,0x5B57,0x5217,0x3092,0x5165,0x529B,0x3057,0x3066,0x304F,0x3060,0x3055,0x3044,0}; |
672 | 672 | char* text2 = "検索文字列"; |
673 | 673 | |
674 | - keyWords[0] = '\0'; | |
675 | - while (running) | |
676 | - { | |
677 | - if(sceCtrlPeekBufferPositive(&pad, 1)) | |
678 | - { | |
679 | - if (pad.Buttons != oldPad.Buttons) | |
680 | - { | |
681 | - oldPad = pad; | |
682 | - if(pad.Buttons & PSP_CTRL_CIRCLE) | |
683 | - { | |
684 | - psp2chGets(text2, keyWords, 128, 1); | |
685 | - } | |
686 | - if(pad.Buttons & PSP_CTRL_CROSS) | |
687 | - { | |
688 | - return -1; | |
689 | - } | |
690 | - if(pad.Buttons & PSP_CTRL_SQUARE) | |
691 | - { | |
692 | - break; | |
693 | - } | |
694 | - } | |
695 | - sceGuStart(GU_DIRECT, list); | |
696 | - sceGuClearDepth(0); | |
697 | - sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); | |
698 | - pgFillvram(BLUE, 100, 60, 280, 45); | |
699 | - pgEditBox(WHITE, 140, 85, 340, 100); | |
700 | - pgCursorX = 142; | |
701 | - pgCursorY = 87; | |
702 | - pgPrint(keyWords, BLACK, WHITE, 340); | |
703 | - pgCopy(0, 0); | |
704 | - pgMenuBar(" ○ : 入力 × : 戻る □ : 決定"); | |
705 | - pgCursorX = 240; | |
706 | - pgCursorY = 77; | |
707 | - intraFontSetStyle(jpn0, 1.0f, YELLOW, 0, INTRAFONT_ALIGN_CENTER); | |
708 | - intraFontPrintUCS2(jpn0, pgCursorX, pgCursorY, text1); | |
709 | - sceGuFinish(); | |
710 | - sceGuSync(0,0); | |
711 | - } | |
712 | - sceDisplayWaitVblankStart(); | |
713 | - framebuffer = sceGuSwapBuffers(); | |
714 | - } | |
715 | - return 0; | |
674 | + return psp2chInputDialog(text1, text2); | |
716 | 675 | } |
717 | 676 | |
718 | 677 | /**************** |
@@ -7,6 +7,9 @@ | ||
7 | 7 | |
8 | 8 | int psp2chMenu(int pixelsX, int pixelsY); |
9 | 9 | void psp2chMenuNG(int pixelsX, int pixelsY); |
10 | +char* psp2chGetNGBuf(const char* file, char* buf); | |
11 | +int psp2chNGDel(const char* file, int pixelsX, int pixelsY); | |
12 | +int psp2chNGAdd(const char* file, char* val); | |
10 | 13 | void psp2chDrawMenu(char** menuList, S_2CH_SCREEN menu, int x, int y, int width, int height); |
11 | 14 | |
12 | 15 | #endif |