// Korean text lists with picture confirmation and bounded batch item additions. module.exports=function(s,enc){ const start=s.indexOf('static void main_menu(void){'), end=s.indexOf('\nstatic void run(void)',start); let menu=s.slice(start,end); const a=menu.indexOf(' rect(0,0,128,128,BG);'),b=menu.indexOf(' show(); wait_release();',a); menu=menu.slice(0,a)+` ko_surface(); ctext(4,"${enc('치트 메뉴')}",RGB(255,255,255),1); for(u32 i=0;i64||h>64)return;int left=(128-(int)(w*sc))/2,top=27+(64-(int)(h*sc))/2;for(u32 y=0;y20u) n=20u;', 'u32 n=fl(o+3)[0]; if(n==255u){u32 a=g_cfg.cat_off+rd32(o+8);u32 i=0;while(i<60u&&fl(a+i)[0]){g_nm[i]=(char)fl(a+i)[0];i++;}g_nm[i]=0;return g_nm;} if(n>20u) n=20u;'); s=s.replace(/static void chr_name\(u32 k, char \*out\)\{[^\n]+/, 'static void chr_name(u32 k, char *out){const char *n=item_name(rd16(g_cfg.cat_off+8u+28u*k));int i=0;while(n[i]&&i<60){out[i]=n[i];i++;}out[i]=0;}'); s=s.replace(/\b(nm|name|st|t)\[24\]/g,'$1[64]'); // Wrap by glyph boundaries rather than splitting a two-byte Korean character. const split=s.indexOf('static const char *item_name'); s=s.slice(0,split)+`static void ko_title(const char *s,int y){int n=0,w=0;while(s[n]){int z=ko_pair(s+n)?2:1,px=z==2?10:6;if(w+px>116)break;w+=px;n+=z;}textn((128-w)/2,y,s,n,WHITE,1);if(s[n])ctext(y+11,s+n,WHITE,1);}\n`+s.slice(split); s=s.replace('if(L<=20) ctext(4,nm,WHITE,1); else { textn(4,2,nm,20,WHITE,1); textn(4,11,nm+20,20,WHITE,1); }','ko_title(nm,2);'); const ui=s.indexOf('static void list_draw('); s=s.slice(0,ui)+`static void ko_surface(void){rect(0,0,128,128,RGB(0,169,209));for(int y=19;y<113;y++)for(int x=0;x<128;x++)if(((x+y)&7)<2)rect(x,y,x+1,y+1,RGB(0,157,199));rect(0,0,128,19,RGB(18,58,112));rect(0,113,128,128,RGB(18,58,112));} static void ko_row(int y,int selected){rect(5,y+2,123,y+14,RGB(18,96,136));rect(3,y+3,125,y+11,RGB(255,255,255));rect(5,y+1,123,y+13,RGB(255,255,255));rect(7,y,121,y+14,RGB(255,255,255));if(selected)for(int x=0;x<5;x++)rect(5+x,y+3+x,6+x,y+11-x,RGB(224,80,152));} `+s.slice(ui); s=s.replace(' rect(0,0,128,128,BG);\n ctext(2,title,WHITE,1);',' ko_surface();\n ctext(4,title,RGB(255,255,255),1);'); s=s.replace('r<10u && top+r10u){ int h=100*10/(int)n; if(h<6) h=6; int y=12+(int)(100-h)*(int)top/(int)(n-10u);','if(n>6u){ int h=90*6/(int)n; if(h<6) h=6; int y=21+(int)(90-h)*(int)top/(int)(n-6u);'); s=s.replace('ctext(118,foot,GREY,1);','ctext(117,foot,RGB(255,255,255),1);'); s=s.replaceAll('if(sel>=top+10u) top=sel-9u;','if(sel>=top+6u) top=sel-5u;'); // The full name and growth stage appear in the picture screen; keep list rows uncluttered. s=s.replace('q<3){ right[q]=fn[q];','q<0){ right[q]=fn[q];'); s=s.replace('fn=fname(f-1u); *col=fcol(f-1u);','fn=fname(f-1u); *col=WHITE;'); const previewStart=s.indexOf(' u32 kk=g_chr[sel]'),previewEnd=s.indexOf(' u32 to=g_cfg.tama_off;',previewStart); if(previewStart<0||previewEnd<0)throw Error('Character preview not found'); s=s.slice(0,previewStart)+` u32 nw=0,st=0,old=t_id();int accepted=0,back=0; while(!accepted&&!back){ u32 kk=g_chr[sel],o=g_cfg.cat_off+8u+28u*kk;nw=rd16(o);st=fl(o+6)[0]; char nm[64];chr_name(kk,nm);rect(0,0,128,128,BG);ko_title(nm,2);ko_portrait(kk); ctext(93,stage_name(st),GREY,1);ctext(105,"${enc('휠 이전 다음')}",GREY,1);ctext(117,"${enc('B 변경 C 목록')}",GREY,1);show();wait_release(); for(;;){int key=input();if(key==1){int next=(int)sel+g_step;if(next<0)next=0;if(next>=(int)g_chrn)next=(int)g_chrn-1;sel=(u32)next;break;}if(key==K_OK){accepted=1;break;}if(key==K_BACK){back=1;break;}} } if(!accepted)break; `+s.slice(previewEnd); // A newly selected item adds the requested amount to the existing stack. The // native save stores each quantity in four bits, so the total cannot exceed 15. const countStart=s.indexOf('#ifdef BAG_DEL\nstatic u32 count_edit('), countEnd=s.indexOf('static int g_dirty;',countStart); if(countStart<0||countEnd<0)throw Error('Item quantity editor not found'); s=s.slice(0,countStart)+`static u32 count_choose(u32 id,u32 v,u32 lo,u32 hi,int adding){ if(vhi)v=hi; for(;;){ rect(0,0,128,128,BG);ko_title(item_name(id),2);draw_item_pic(id,64,54,60); char num[8];utoa_(v,num); text(20,87,adding?"${enc('추가')}":"${enc('수량')}",WHITE,1);text(65,85,num,GOLD,2);text(103,87,"${enc('개')}",WHITE,1); ctext(105,"${enc('휠 수량 조절')}",GREY,1);ctext(117,"${enc('B 확인 C 목록')}",GREY,1);show();wait_release(); for(;;){int k=input(); if(k==1){int nv=(int)v+g_step;if(nv<(int)lo)nv=(int)lo;if(nv>(int)hi)nv=(int)hi;v=(u32)nv;break;} if(k==K_A){if(v=15u){message("${enc('최대 15개 보유')}","${enc('더 추가할 수 없습니다')}","");return 16u;} u32 n=count_choose(id,1u,1u,15u-owned,1);return n==16u?16u:owned+n; } `+s.slice(countEnd); s=s.replace('count_edit(id, slot=0&&names){for(u32 j=0;j<26;j++)g_page[226u+j]=fl(names+26u*(u32)k+j)[0];g_page[0xfcu]=fl(g_cfg.cat_off+8u+28u*(u32)k+6u)[0];g_page[0xfdu]=0;} u32 sum=rd32(a)-before;for(u32 z=8;z<0x180;z+=4)sum+=*(u32*)(g_page+z);*(u32*)g_page=sum;*(u32*)(g_page+4u)=0u-sum; } flash_prog4k(a, g_page); n++;`); s=s.replace('RGB(60,60,110)','RGB(205,225,169)').replace('RGB(40,40,70)','BG'); s=s.replace('if(k>=0 && fl(g_cfg.cat_off+8u+28u*(u32)k+2u)[0]==2u){ char t[64]; chr_name((u32)k,t); t[15]=0;', 'if(k>=0 && fl(g_cfg.cat_off+8u+28u*(u32)k+2u)[0]==2u){ char t[64]; chr_name((u32)k,t); int z=0;while(t[z]&&z+(ko_pair(t+z)?2:1)<=14)z+=ko_pair(t+z)?2:1;t[z]=0;'); return s; };