Skip to content
Closed
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
2 changes: 2 additions & 0 deletions desktop_version/src/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* FIXME: This should include more constants!
*/

#define NO_DATA_ZIP_TITLE "Error: missing data.zip!"
#define NO_DATA_ZIP "\nYou do not have data.zip!\nGrab it from your purchased copy of the game, or get it from the free Make and Play Edition.\n\nIf you are getting this error, and you do\n have data.zip, move it into the folder\ncontaining the executable.\n"
#define SCREEN_WIDTH_TILES 40
#define SCREEN_HEIGHT_TILES 30

Expand Down
46 changes: 37 additions & 9 deletions desktop_version/src/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ void editorclass::reset(void)
note = "";
note_timer = 0;
old_note_timer = 0;
old_keybuffer = "";
backspace_held = false;
current_text_mode = TEXT_NONE;

Expand Down Expand Up @@ -1915,7 +1916,8 @@ void editorrender(void)
// Draw cursor
if (ed.entframe < 2)
{
font::print(PR_FONT_LEVEL | PR_CJK_LOW, 16 + font::len(PR_FONT_LEVEL, ed.script_buffer[ed.script_cursor_y].c_str()), 20 + ((ed.script_cursor_y - ed.script_offset) * font_height), "_", 123, 111, 218);
// FIXME: Ugly and shitty workaround for the X cursor should be avoided
font::print(PR_FONT_LEVEL | PR_CJK_LOW, 16 + (font::len(PR_FONT_LEVEL, "a")*ed.script_cursor_x), 20 + ((ed.script_cursor_y - ed.script_offset) * font_height), "_", 123, 111, 218);
}
break;
}
Expand Down Expand Up @@ -3767,6 +3769,7 @@ void editorinput(void)
music.playef(Sound_VIRIDIAN);
}
}

break;
}
case EditorSubState_SCRIPTS_EDIT:
Expand All @@ -3787,32 +3790,48 @@ void editorinput(void)

if (up_pressed && ed.keydelay <= 0)
{
ed.keydelay = 3;
ed.keydelay = 6;
ed.script_cursor_y = SDL_max(0, ed.script_cursor_y - 1);

key.keybuffer = ed.script_buffer[ed.script_cursor_y];
}

if (down_pressed && ed.keydelay <= 0)
{
ed.keydelay = 3;
ed.keydelay = 6;
ed.script_cursor_y = SDL_min((int) ed.script_buffer.size() - 1, ed.script_cursor_y + 1);

key.keybuffer = ed.script_buffer[ed.script_cursor_y];
}

if (left_pressed && ed.keydelay <= 0)
{
ed.keydelay = 6;
ed.script_cursor_x = SDL_max(0, ed.script_cursor_x - 1);
}
if (right_pressed && ed.keydelay <= 0)
{
ed.keydelay = 6;
ed.script_cursor_x = SDL_min((int) UTF8_total_codepoints(ed.script_buffer[ed.script_cursor_y].c_str()), ed.script_cursor_x + 1);
}

if (key.linealreadyemptykludge)
{
ed.keydelay = 6;
key.linealreadyemptykludge = false;
}

if (key.pressedbackspace && ed.script_buffer[ed.script_cursor_y] != "" && ed.keydelay <= 0)
{
ed.script_buffer[ed.script_cursor_y].erase(ed.script_cursor_x-1, 1);
if(ed.script_cursor_x > 0)
ed.script_cursor_x = ed.script_cursor_x - 1;
ed.keydelay = 2;
}
if (key.pressedbackspace && ed.script_buffer[ed.script_cursor_y] == "" && ed.keydelay <= 0)
{
//Remove this line completely
ed.remove_line(ed.script_cursor_y);
ed.script_cursor_y = SDL_max(0, ed.script_cursor_y - 1);
key.keybuffer = ed.script_buffer[ed.script_cursor_y];
ed.script_cursor_x = UTF8_total_codepoints(ed.script_buffer[ed.script_cursor_y].c_str());
ed.keydelay = 6;
}

Expand All @@ -3826,8 +3845,17 @@ void editorinput(void)
}
}}

ed.script_buffer[ed.script_cursor_y] = key.keybuffer;
ed.script_cursor_x = UTF8_total_codepoints(ed.script_buffer[ed.script_cursor_y].c_str());
if(ed.old_keybuffer.length() < key.keybuffer.length()) {
std::string keybufcopy = key.keybuffer;
std::string addition = keybufcopy.erase(0, ed.old_keybuffer.length());
//printf("Addition %s, keyBuffer %s\n", addition.c_str(), key.keybuffer.c_str());

ed.script_buffer[ed.script_cursor_y].insert(ed.script_cursor_x, addition);
ed.script_cursor_x = ed.script_cursor_x + addition.length();

}

//ed.script_buffer[ed.script_cursor_y] = key.keybuffer;

if (enter_pressed)
{
Expand Down Expand Up @@ -3859,7 +3887,7 @@ void editorinput(void)
{
ed.script_offset = SDL_min((int) ed.script_buffer.size() - ed.lines_visible + SCRIPT_LINE_PADDING, ed.script_cursor_y - ed.lines_visible + SCRIPT_LINE_PADDING);
}

ed.old_keybuffer = key.keybuffer;
break;
}
default:
Expand Down
1 change: 1 addition & 0 deletions desktop_version/src/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class editorclass
int old_note_timer;
std::string note;
std::string keybuffer;
std::string old_keybuffer; // !!! at the moment for use with script editor only
std::string filename;
std::string loaded_filepath;

Expand Down
23 changes: 9 additions & 14 deletions desktop_version/src/FileSystemUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD
"saves",
pathSep
);
mkdir(saveDir, 0777);
mkdir(saveDir, 0755);
vlog_info("Save directory: %s", saveDir);

/* Store full level directory */
Expand All @@ -258,7 +258,7 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD
"levels",
pathSep
);
mkdir(levelDir, 0777);
mkdir(levelDir, 0755);
vlog_info("Level directory: %s", levelDir);

/* Store full screenshot directory */
Expand All @@ -267,7 +267,7 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD
"screenshots",
pathSep
);
mkdir(screenshotDir, 0777);
mkdir(screenshotDir, 0755);
vlog_info("Screenshot directory: %s", screenshotDir);

/* We also need to make the subdirectories */
Expand All @@ -276,11 +276,11 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD
SDL_snprintf(temp, sizeof(temp), "%s%s%s",
screenshotDir, "1x", pathSep
);
mkdir(temp, 0777);
mkdir(temp, 0755);
SDL_snprintf(temp, sizeof(temp), "%s%s%s",
screenshotDir, "2x", pathSep
);
mkdir(temp, 0777);
mkdir(temp, 0755);
}

basePath = SDL_GetBasePath();
Expand Down Expand Up @@ -329,17 +329,12 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD
if (!PHYSFS_mount(output, NULL, 1))
#endif
{
vlog_error("Error: data.zip missing!");
vlog_error("You do not have data.zip!");
vlog_error("Grab it from your purchased copy of the game,");
vlog_error("or get it from the free Make and Play Edition.");
vlog_error(NO_DATA_ZIP_TITLE NO_DATA_ZIP);

SDL_ShowSimpleMessageBox(
SDL_MESSAGEBOX_ERROR,
"data.zip missing!",
"You do not have data.zip!"
"\n\nGrab it from your purchased copy of the game,"
"\nor get it from the free Make and Play Edition.",
NO_DATA_ZIP_TITLE,
NO_DATA_ZIP,
NULL
);
VVV_exit(1);
Expand Down Expand Up @@ -1317,7 +1312,7 @@ static int PLATFORM_getOSDirectory(char* output, const size_t output_size)
}

SDL_strlcat(output, "\\VVVVVV\\", MAX_PATH);
mkdir(output, 0777);
mkdir(output, 0755);
return 1;
#elif defined(__ANDROID__)
const char* externalStoragePath = SDL_AndroidGetExternalStoragePath();
Expand Down