• R/O
  • SSH
  • HTTPS

owata: Commit


Commit MetaInfo

Revision12 (tree)
Time2008-02-26 12:49:52
Authorbird_may_nike

Log Message

NGメニューを有効に

Change Summary

Incremental Difference

--- trunc/src/psp2ch.c (revision 11)
+++ trunc/src/psp2ch.c (revision 12)
@@ -29,6 +29,9 @@
2929 extern int running; //main.c
3030 extern char cwDir[256]; //main.c
3131 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
3235
3336 int tateFlag = 0;
3437 int sel = 0;
@@ -35,6 +38,7 @@
3538 const char* userAgent = "Monazilla/1.00 (Compatible; PSP; ja) owata\(^o^)/0.4.3";
3639 const char* logDir = "log";
3740 char cookie[128] = {0};
41+char keyWords[128];
3842 SceCtrlData pad;
3943 SceCtrlData oldPad;
4044 MESSAGE_HELPER mh;
@@ -1162,3 +1166,55 @@
11621166 }
11631167 s[i] = '\0';
11641168 }
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+}
--- trunc/src/psp2ch.h (revision 11)
+++ trunc/src/psp2ch.h (revision 12)
@@ -124,5 +124,6 @@
124124 int psp2chGetHttpHeaders(int mySocket, HTTP_HEADERS* header);
125125 int psp2chApConnect(void);
126126 void psp2chGets(char* title, char* text, int num, int lines);
127+int psp2chInputDialog(const unsigned short* text1, char* text2);
127128
128129 #endif
--- trunc/src/psp2chRes.c (revision 11)
+++ trunc/src/psp2chRes.c (revision 12)
@@ -40,6 +40,8 @@
4040 extern S_2CH_HEADER_COLOR resHeaderColor; // psp2ch.c
4141 extern S_2CH_RES_COLOR resColor; // psp2ch.c
4242 extern S_2CH_BAR_COLOR resBarColor; // psp2ch.c
43+extern const char* ngNameFile;
44+extern const char* ngIDFile;
4345
4446 int preLine = -2;
4547 char* resBuffer = NULL;
@@ -134,6 +136,12 @@
134136 else if(pad.Buttons & PSP_CTRL_START)
135137 {
136138 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;
137145 }
138146 // ○ボタン
139147 else if(pad.Buttons & PSP_CTRL_CIRCLE)
@@ -312,26 +320,40 @@
312320 }
313321 else
314322 {
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)
322324 {
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)
328329 {
329- threadList[threadSort[thread.select]].old = 0;
330- psp2chSort(-1);
330+ res.start = totalLine - lineEnd;
331331 }
332- sel = ret;
333- return 0;
332+ preLine = -2;
334333 }
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+ }
335357 }
336358 }
337359 }
@@ -388,7 +410,7 @@
388410 }
389411 else if (idMenu >= 0)
390412 {
391- menuStr = " ○ : ID抽出   ";
413+ menuStr = " ○ : ID抽出   □ : NGID登録";
392414 }
393415 else if (rMenu)
394416 {
@@ -570,8 +592,11 @@
570592 for (i = 0, j = 0; i < res.count; i++)
571593 {
572594 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+ }
575600 }
576601 }
577602 else
@@ -584,8 +609,11 @@
584609 for (i = 0, j = 0; i < res.count; i++)
585610 {
586611 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+ }
589617 }
590618 }
591619 bar->total = j * LINE_PITCH;
@@ -727,6 +755,72 @@
727755 }
728756
729757 /*****************************
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+/*****************************
730824 datファイルをメモリに読み込みデータの区切りを'\0'(文字列終端)に書き換える
731825 resList構造体のポインタに各データのアドレスを代入
732826 *****************************/
@@ -935,8 +1029,8 @@
9351029 p++;
9361030 buf = p;
9371031 resList[ret].num = ret;
938- resList[ret].ng = 0;
9391032 }
1033+ psp2chResCheckNG();
9401034 psp2chSaveIdx(title, dat);
9411035 return 0;
9421036 }
@@ -1582,6 +1676,16 @@
15821676 pgCursorY = (LINE_PITCH*drawLine)&0x01FF;
15831677 resAnchorCount = 0;
15841678 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+ }
15851689 line = 0;
15861690 while (line <= lineEnd)
15871691 {
--- trunc/src/psp2chRes.h (revision 11)
+++ trunc/src/psp2chRes.h (revision 12)
@@ -59,6 +59,7 @@
5959 int psp2chResCursorMove(int* totalLine, int* lineEnd, int* cursorY, int limitY);
6060 int psp2chResSetLine(S_SCROLLBAR* bar);
6161 void psp2chResPadMove(int* cursorX, int* cursorY, int limitX, int limitY);
62+void psp2chResCheckNG(void);
6263 int psp2chResList(char* host, char* dir, char* title, int dat);
6364 int psp2chGetDat(char* host, char* dir, char* title, int dat);
6465 void psp2chSaveIdx(char* title, int dat);
--- trunc/src/pg.c (revision 11)
+++ trunc/src/pg.c (revision 12)
@@ -391,7 +391,7 @@
391391 if (tateFlag)
392392 {
393393 tmp = x1;
394- x1 = SCR_WIDTH - y2;
394+ x1 = SCR_WIDTH - y2 + 1;
395395 y2 = x2;
396396 x2 = SCR_WIDTH - y1;
397397 y1 = tmp;
--- trunc/src/psp2chMenu.c (revision 11)
+++ trunc/src/psp2chMenu.c (revision 12)
@@ -4,6 +4,7 @@
44
55 #include "pspdialogs.h"
66 #include <stdio.h>
7+#include <malloc.h>
78 #include <pspdebug.h>
89 #include <pspctrl.h>
910 #include "pg.h"
@@ -23,19 +24,24 @@
2324 extern SceCtrlData oldPad; // psp2ch.c
2425 extern MESSAGE_HELPER mh; // psp2ch.c
2526 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;
2630
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";
3033
3134 /****************
3235 メニュー選択ウィンドウ
3336 ****************/
37+#define MENU_WIDTH (80)
38+#define MENU_HEIGHT (52)
39+#define MENU_ITEM (4)
3440 int psp2chMenu(int pixelsX, int pixelsY)
3541 {
42+ const char* menuList[] = {"NG設定"};
3643 static char* menuStr = "";
3744 int lineEnd;
38- const char* menuList[] = {"基本設定", "NG設定"};
3945 static S_2CH_SCREEN menu;
4046 int startX, startY, scrX, scrY;
4147
@@ -45,13 +51,13 @@
4551 startY = (SCR_WIDTH - MENU_HEIGHT) / 2; }
4652 else
4753 {
48- startX = (SCR_WIDTH - 100) / 2;
54+ startX = (SCR_WIDTH - MENU_WIDTH) / 2;
4955 startY = (SCR_HEIGHT - MENU_HEIGHT) / 2;
5056 }
51- scrX = 100;
57+ scrX = MENU_WIDTH;
5258 scrY = MENU_HEIGHT;
5359 lineEnd = MENU_ITEM;
54- menu.count = 2;
60+ menu.count = 1;
5561 printBuf = winPixels;
5662 while (running)
5763 {
@@ -66,11 +72,16 @@
6672 switch (menu.select)
6773 {
6874 case 0:
75+ psp2chMenuNG(pixelsX, pixelsY);
6976 break;
7077 case 1:
71- psp2chMenuNG(pixelsX, pixelsY);
7278 break;
7379 }
80+ printBuf = pixels;
81+ pgCopy(pixelsX, pixelsY);
82+ framebuffer = sceGuSwapBuffers();
83+ pgCopy(pixelsX, pixelsY);
84+ printBuf = winPixels;
7485 }
7586 else if(pad.Buttons & PSP_CTRL_CROSS)
7687 {
@@ -96,26 +107,34 @@
96107 return 0;
97108 }
98109
110+/****************
111+NG設定ウィンドウ
112+****************/
113+#define MENU_NG_WIDTH (80)
114+#define MENU_NG_HEIGHT (52)
115+#define MENU_NG_ITEM (4)
99116 void psp2chMenuNG(int pixelsX, int pixelsY)
100117 {
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削除"};
101121 static char* menuStr = "";
102122 int lineEnd;
103- const char* menuList[] = {"NG名前登録", "NG名前削除", "NGID削除"};
104123 static S_2CH_SCREEN menu;
105124 int startX, startY, scrX, scrY;
106125
107126 if (tateFlag)
108127 {
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; }
111130 else
112131 {
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;
115134 }
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;
119138 menu.count = 3;
120139 printBuf = pixels;
121140 pgCopy(pixelsX, pixelsY);
@@ -135,12 +154,26 @@
135154 switch (menu.select)
136155 {
137156 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+ }
138164 break;
139165 case 1: // NG name del
166+ psp2chNGDel(ngNameFile, pixelsX, pixelsY);
140167 break;
141168 case 2: // NG ID del
169+ psp2chNGDel(ngIDFile, pixelsX, pixelsY);
142170 break;
143171 }
172+ printBuf = pixels;
173+ pgCopy(pixelsX, pixelsY);
174+ framebuffer = sceGuSwapBuffers();
175+ pgCopy(pixelsX, pixelsY);
176+ printBuf = winPixels;
144177 }
145178 else if(pad.Buttons & PSP_CTRL_CROSS)
146179 {
@@ -158,15 +191,231 @@
158191 }
159192 }
160193
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+****************/
161396 void psp2chDrawMenu(char** menuList, S_2CH_SCREEN menu, int x, int y, int width, int height)
162397 {
163- int i;
398+ int i, start, lineEnd;
164399
165400 pgCursorX = x;
166401 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+ }
167412 pgFillvram(menuWinColor.bg, x, y, width, height);
168- for (i = 0; i < menu.count; i++)
413+ for (i = start; i < start + lineEnd; i++)
169414 {
415+ if (i >= menu.count)
416+ {
417+ return;
418+ }
170419 if (i == menu.select)
171420 {
172421 pgFillvram(menuWinColor.s_bg, x, pgCursorY, width, LINE_PITCH);
@@ -180,4 +429,3 @@
180429 pgCursorY += LINE_PITCH;
181430 }
182431 }
183-
--- trunc/src/psp2chThread.c (revision 11)
+++ trunc/src/psp2chThread.c (revision 12)
@@ -36,11 +36,11 @@
3636 extern int preLine; // psp2chRes.c
3737 extern S_2CH_THREAD_COLOR threadColor; // psp2ch.c
3838 extern S_2CH_FAVORITE* findList; // psp2chSearch.c
39+extern char keyWords[128]; //psp2ch.c
3940
4041 S_2CH_THREAD* threadList;
4142 S_2CH_SCREEN thread;
4243 int* threadSort = NULL;
43-char keyWords[128];
4444
4545 /****************
4646 スレッド一覧表示
@@ -671,48 +671,7 @@
671671 const unsigned short text1[] = {0x691C,0x7D22,0x6587,0x5B57,0x5217,0x3092,0x5165,0x529B,0x3057,0x3066,0x304F,0x3060,0x3055,0x3044,0};
672672 char* text2 = "検索文字列";
673673
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);
716675 }
717676
718677 /****************
--- trunc/src/psp2chMenu.h (revision 11)
+++ trunc/src/psp2chMenu.h (revision 12)
@@ -7,6 +7,9 @@
77
88 int psp2chMenu(int pixelsX, int pixelsY);
99 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);
1013 void psp2chDrawMenu(char** menuList, S_2CH_SCREEN menu, int x, int y, int width, int height);
1114
1215 #endif
Show on old repository browser