Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions arm9/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2432,14 +2432,14 @@ void handleClearFx(void)
setEffectCommand(0xff);
pv->clearSelection();
}
void showTypewriter(const char *prompt, const char *str, void (*okCallback)(void), void (*clearCallback)(void), void (*cancelCallback)(void))
void showTypewriter(const char *prompt, const char *str, void (*okCallback)(void), void (*clearCallback)(void), void (*cancelCallback)(void), bool is_file_name)
{
// TODO: Migrate to new TobKit to eliminate such ugliness
#define SUB_BG1_X0 (*(vuint16*)0x04001014)
#define SUB_BG1_Y0 (*(vuint16*)0x04001016)

tw = new Typewriter(prompt, (uint16*)CHAR_BASE_BLOCK_SUB(1),
(uint16*)SCREEN_BASE_BLOCK_SUB(12), 3, &sub_vram, &SUB_BG1_X0, &SUB_BG1_Y0);
(uint16*)SCREEN_BASE_BLOCK_SUB(12), 3, &sub_vram, &SUB_BG1_X0, &SUB_BG1_Y0, is_file_name);
tw->setTheme(settings->getTheme(), settings->getTheme()->col_bg);
tw->setText(str);
gui->registerOverlayWidget(tw, mykey_LEFT|mykey_RIGHT, SUB_SCREEN);
Expand All @@ -2458,7 +2458,7 @@ void showTypewriter(const char *prompt, const char *str, void (*okCallback)(void


void showTypewriterForFilename(void) {
showTypewriter("filename", labelFilename->getCaption(), handleTypewriterFilenameOk, clearTypewriterText, deleteTypewriter);
showTypewriter("filename", labelFilename->getCaption(), handleTypewriterFilenameOk, clearTypewriterText, deleteTypewriter, true);
}

void handleTypewriterNewFolderOk(void)
Expand All @@ -2474,7 +2474,7 @@ void handleTypewriterNewFolderOk(void)
}

void showTypewriterForNewFolder(void) {
showTypewriter("dir name", "", handleTypewriterNewFolderOk, clearTypewriterText, deleteTypewriter);
showTypewriter("dir name", "", handleTypewriterNewFolderOk, clearTypewriterText, deleteTypewriter, true);
}

void handleTypewriterInstnameOk(void)
Expand All @@ -2493,7 +2493,7 @@ void showTypewriterForInstRename(void)
return;
}

showTypewriter("inst name", lbinstruments->get(lbinstruments->getidx()), handleTypewriterInstnameOk, clearTypewriterText, deleteTypewriter);
showTypewriter("inst name", lbinstruments->get(lbinstruments->getidx()), handleTypewriterInstnameOk, clearTypewriterText, deleteTypewriter, false);
}

void handleTypewriterSongnameOk(void)
Expand All @@ -2505,7 +2505,7 @@ void handleTypewriterSongnameOk(void)

void showTypewriterForSongRename(void)
{
showTypewriter("song name", song->getName(), handleTypewriterSongnameOk, clearTypewriterText, deleteTypewriter);
showTypewriter("song name", song->getName(), handleTypewriterSongnameOk, clearTypewriterText, deleteTypewriter, false);
}

void handleTypewriterSampleOk(void)
Expand Down Expand Up @@ -2549,7 +2549,7 @@ void showTypewriterForSampleRename(void)
if(sample == 0)
return;

showTypewriter("sample name", lbsamples->get(lbsamples->getidx()), handleTypewriterSampleOk, clearTypewriterText, deleteTypewriter);
showTypewriter("sample name", lbsamples->get(lbsamples->getidx()), handleTypewriterSampleOk, clearTypewriterText, deleteTypewriter, false);
}

void handleRecordSampleOK(void)
Expand Down
3 changes: 2 additions & 1 deletion themes/Default.nttheme
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@
108=8394c5 ; FX input keyboard command description label
109=ff9400 ; FX input keyboard command description label (disabled)
110=4a7bff ; FX input keyboard button "X" label
111=ff62ee ; FX input keyboard button "Y" label
111=ff62ee ; FX input keyboard button "Y" label
112=cfcfcf ; Text entry disabled key
Binary file modified tobkit/graphics/typewriter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion tobkit/include/tobkit/theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ limitations under the License.
#include "../../arm9/source/tools.h"
#include <nds.h>

#define NUM_COLORS 112
#define NUM_COLORS 113

namespace tobkit {

Expand Down Expand Up @@ -142,6 +142,7 @@ struct ColorScheme {
u16 col_fxkeyboard_cmd_desc_disabled;
u16 col_fxkeyboard_minilabel_x;
u16 col_fxkeyboard_minilabel_y;
u16 col_typewriter_disabled_key;
};
};

Expand Down
7 changes: 4 additions & 3 deletions tobkit/include/tobkit/typewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Typewriter: public Widget {
public:
Typewriter(/*u8 _x, u8 _y,*/const char *_msg, u16 *_char_base,
u16 *_map_base, u8 _palette_offset, uint16 **_vram,
vuint16* _trans_reg_x, vuint16* _trans_reg_y);
vuint16* _trans_reg_x, vuint16* _trans_reg_y, bool _is_file_name);

~Typewriter(void);

Expand All @@ -57,7 +57,7 @@ class Typewriter: public Widget {
void setTheme(Theme *theme_, u16 bgcolor_);

private:
unsigned short typewriterPal[16] __attribute__((aligned(4)));
unsigned short typewriterPal[16];


void (*onOk)(void);
Expand All @@ -78,9 +78,10 @@ class Typewriter: public Widget {
u8 mode;
vuint16 *trans_reg_x, *trans_reg_y;

bool is_file_name;
char *text;
u16 cursorpos, strlength;

u8 tilex, tiley;

void genPal(void);
Expand Down
3 changes: 3 additions & 0 deletions tobkit/source/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ ColorScheme::ColorScheme() {
col_fxkeyboard_cmd_desc_disabled = col_dark_ctrl_disabled;
col_fxkeyboard_minilabel_x = col_pv_notes &~ BIT(15);
col_fxkeyboard_minilabel_y = col_pv_effect &~ BIT(15);
col_typewriter_disabled_key = RGB15(25, 25, 25) | BIT(15);
}

Theme::Theme(char* themepath, bool use_fat)
Expand Down Expand Up @@ -248,6 +249,8 @@ bool Theme::parseTheme(FILE* theme_, u16* theme_cols) {
if (!theme_has_key[109]) theme_cols[109] = theme_cols[8]; // Fxkb disabled command desc label
if (!theme_has_key[110]) theme_cols[110] = theme_cols[61]; // Fxkb button param label 'X'
if (!theme_has_key[111]) theme_cols[111] = theme_cols[67]; // Fxkb button param label 'Y'
if (!theme_has_key[112]) theme_cols[112] = theme_cols[93]; // Typewriter disabled key


return true;
}
25 changes: 16 additions & 9 deletions tobkit/source/typewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ using namespace tobkit;

Typewriter::Typewriter(const char *_msg, u16 *_char_base,
u16 *_map_base, u8 _palette_offset, uint16 **_vram, vuint16* _trans_reg_x,
vuint16* _trans_reg_y)
vuint16* _trans_reg_y, bool _is_file_name)
:Widget((SCREEN_WIDTH-TW_WIDTH)/2, (SCREEN_HEIGHT-TW_HEIGHT)/2-15, TW_WIDTH, TW_HEIGHT, _vram),
char_base(_char_base), map_base(_map_base), palette_offset(_palette_offset),
kx(x+TW_TILE_X), ky(y+TW_TILE_Y),
mode(TYPEWRITER_MODE_NORMAL),
trans_reg_x(_trans_reg_x), trans_reg_y(_trans_reg_y), cursorpos(0), strlength(0)
trans_reg_x(_trans_reg_x), trans_reg_y(_trans_reg_y),
is_file_name(_is_file_name), cursorpos(0), strlength(0)
{
onOk = 0;
onCancel = 0;
Expand Down Expand Up @@ -96,13 +97,14 @@ Typewriter::~Typewriter(void)

void Typewriter::genPal(void)
{
const u16 tw_themecols[6] = {
const u16 tw_themecols[] = {
theme->col_typewriter_mod_key, theme->col_typewriter_key,
theme->col_typewriter_key_label, theme->col_typewriter_bg,
theme->col_outline, theme->col_typewriter_mod_key_label
theme->col_outline, theme->col_typewriter_mod_key_label,
(is_file_name ? theme->col_typewriter_disabled_key : theme->col_typewriter_key)
};

memcpy(&typewriterPal[1], tw_themecols, 6 * sizeof(u16));
memcpy(&typewriterPal[1], tw_themecols, 7 * sizeof(u16));
}
// Drawing request
void Typewriter::pleaseDraw(void) {
Expand All @@ -118,8 +120,6 @@ void Typewriter::penDown(u8 px, u8 py)
tilex = (px-kx)/8;
tiley = (py-ky)/8;

setTile(tilex, tiley, 4);

if(tilex>=1 && tilex<(TW_TILE_WIDTH-1) && tiley<TW_TILE_HEIGHT)
{
char c;
Expand All @@ -128,6 +128,13 @@ void Typewriter::penDown(u8 px, u8 py)
else
c = typewriter_Hit[tilex+(tiley*TW_TILE_WIDTH)];

if (is_file_name && strchr("*:<>|\"\?\x7F", c))
{
c = NOK;
} else {
setTile(tilex, tiley, 4);
}

if(c==CAP)
{
if((mode==TYPEWRITER_MODE_CAPS)||(mode==TYPEWRITER_MODE_SHIFT)) {
Expand Down Expand Up @@ -270,7 +277,7 @@ void Typewriter::setTheme(Theme *theme_, u16 bgcolor_)
memcpy(BG_PALETTE_SUB+palette_offset*16, typewriterPal, 32);
// generate highlight palette
for (int i = 0; i < 16; i++) {
BG_PALETTE_SUB[palette_offset * 16 + 16 + i] = (i == 1 || i == 2) ? theme->col_typewriter_pressed_key : theme->col_typewriter_bg;
BG_PALETTE_SUB[palette_offset * 16 + 16 + i] = (i == 1 || i == 2 || i == 7) ? theme->col_typewriter_pressed_key : theme->col_typewriter_bg;
}
}

Expand Down Expand Up @@ -387,4 +394,4 @@ void Typewriter::setTile(int x, int y, int pal)
x2 = x;
y2--;
}
}
}
Loading