Skip to content

Commit

Permalink
Merge branch 'dev' of git@github.com:dacap/aseprite.git into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Oct 14, 2013
2 parents 251e651 + d9910f8 commit 7657461
Show file tree
Hide file tree
Showing 127 changed files with 1,033 additions and 633 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Expand Up @@ -220,6 +220,9 @@ if(WIN32)
# Windows XP is the minimum supported platform.
add_definitions(-D_WIN32_WINNT=0x0501 -DWINVER=0x0501)

# We need Unicode support
add_definitions(-DUNICODE -D_UNICODE)

endif(WIN32)

# -- Mac OS X --
Expand Down
2 changes: 1 addition & 1 deletion config.h
Expand Up @@ -32,7 +32,7 @@
#endif

// General information
#define PACKAGE "ASEPRITE"
#define PACKAGE "Aseprite"
#define VERSION "0.9.6-dev"
#define WEBSITE "http://www.aseprite.org/"
#define COPYRIGHT "Copyright (C) 2001-2013 David Capello"
Expand Down
2 changes: 1 addition & 1 deletion src/allegro/include/allegro/config.h
Expand Up @@ -54,7 +54,7 @@ AL_FUNC(void, set_config_id, (AL_CONST char *section, AL_CONST char *name, int v

AL_FUNC(int, list_config_entries, (AL_CONST char *section, AL_CONST char ***names));
AL_FUNC(int, list_config_sections, (AL_CONST char ***names));
AL_FUNC(void, free_config_entries, (AL_CONST char ***names));
AL_FUNC(void, free_config_entries, (char ***names));

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion src/allegro/include/allegro/platform/aintwin.h
Expand Up @@ -69,7 +69,7 @@ AL_FUNC(void, save_window_pos, (void));
/* main window */
#define WND_TITLE_SIZE 128

AL_ARRAY(char, wnd_title);
AL_ARRAY(wchar_t, wnd_title);
AL_VAR(int, wnd_x);
AL_VAR(int, wnd_y);
AL_VAR(int, wnd_width);
Expand Down
2 changes: 1 addition & 1 deletion src/allegro/src/config.c
Expand Up @@ -1513,7 +1513,7 @@ int list_config_sections(AL_CONST char ***names)
* Frees the entries list returned by list_config_entires or
* list_config_sections again.
*/
void free_config_entries(AL_CONST char ***names)
void free_config_entries(char ***names)
{
_AL_FREE(*names);
*names = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/allegro/src/file.c
Expand Up @@ -1961,7 +1961,7 @@ PACKFILE *pack_fopen_chunk(PACKFILE *f, int pack)
do {
size = new_size;
tmp_dir = _AL_REALLOC(tmp_dir, size);
new_size = GetTempPath(size, tmp_dir);
new_size = GetTempPathA(size, tmp_dir);
} while ( (size < new_size) && (new_size > 0) );

/* Check if we retrieved the path OK */
Expand Down
30 changes: 30 additions & 0 deletions src/allegro/src/win/utf8.h
@@ -0,0 +1,30 @@
// Copyright (C) 2013 by David Capello

#ifndef ALLEGRO_WIN_UTF8_H
#define ALLEGRO_WIN_UTF8_H

static char* convert_widechar_to_utf8(const wchar_t* wstr)
{
char* u8str;
int wlen = wcslen(wstr);
int u8len = WideCharToMultiByte(CP_UTF8, 0, wstr, wlen, NULL, 0, NULL, NULL);
u8len++;
u8str = _AL_MALLOC(u8len);
u8str[u8len-1] = 0;
WideCharToMultiByte(CP_UTF8, 0, wstr, wlen, u8str, u8len, NULL, NULL);
return u8str;
}

static wchar_t* convert_utf8_to_widechar(const char* u8str)
{
wchar_t* wstr;
int u8len = strlen(u8str);
int wlen = MultiByteToWideChar(CP_UTF8, 0, u8str, u8len, NULL, 0);
wlen++;
wstr = _AL_MALLOC(wlen * sizeof(wchar_t));
wstr[wlen-1] = 0;
MultiByteToWideChar(CP_UTF8, 0, u8str, u8len, wstr, wlen);
return wstr;
}

#endif
10 changes: 5 additions & 5 deletions src/allegro/src/win/wdxver.c
Expand Up @@ -105,7 +105,7 @@ int get_dx_ver(void)
}

/* First check for DX 8 and 9 */
dsetup_hinst = LoadLibrary( "DSETUP.DLL" );
dsetup_hinst = LoadLibrary( L"DSETUP.DLL" );
if ( dsetup_hinst ) {
DSetupCreate = (DSETUPCREATE)GetProcAddress(dsetup_hinst, "DirectXSetupGetVersion");
if ( DSetupCreate ) {
Expand Down Expand Up @@ -171,10 +171,10 @@ int get_dx_ver(void)
dx_version = 0x200;

/* we are not supposed to be able to tell which SP we are on, so check for DInput */
dinput_hinst = LoadLibrary("DINPUT.DLL");
dinput_hinst = LoadLibrary(L"DINPUT.DLL");
if (!dinput_hinst) {
/* no DInput... must be DX2 on NT 4 pre-SP3 */
OutputDebugString("Couldn't LoadLibrary DInput\r\n");
OutputDebugString(L"Couldn't LoadLibrary DInput\r\n");
return dx_version;
}

Expand All @@ -200,7 +200,7 @@ int get_dx_ver(void)
/* now we know we are in Windows 9x (or maybe 3.1), so anything's possible;
* first see if DDRAW.DLL even exists.
*/
ddraw_hinst = LoadLibrary("DDRAW.DLL");
ddraw_hinst = LoadLibrary(L"DDRAW.DLL");
if (!ddraw_hinst) {
dx_version = 0;
goto End;
Expand Down Expand Up @@ -236,7 +236,7 @@ int get_dx_ver(void)
dx_version = 0x200;

/* see if we can create the DirectInput object */
dinput_hinst = LoadLibrary("DINPUT.DLL");
dinput_hinst = LoadLibrary(L"DINPUT.DLL");
if (!dinput_hinst) {
/* no DInput... must be DX2 */
goto End;
Expand Down
56 changes: 32 additions & 24 deletions src/allegro/src/win/wsystem.c
Expand Up @@ -25,6 +25,7 @@
#include "allegro.h"
#include "allegro/internal/aintern.h"
#include "allegro/platform/aintwin.h"
#include "utf8.h"

#ifndef ALLEGRO_WINDOWS
#error something is wrong with the makefile
Expand Down Expand Up @@ -235,10 +236,10 @@ static void sys_directx_exit(void)
*/
static void sys_directx_get_executable_name(char *output, int size)
{
char *temp = _AL_MALLOC_ATOMIC(size);
wchar_t* temp = _AL_MALLOC_ATOMIC(size);

if (GetModuleFileName(allegro_inst, temp, size))
do_uconvert(temp, U_ASCII, output, U_CURRENT, size);
do_uconvert((char*)temp, U_UNICODE, output, U_CURRENT, size);
else
usetc(output, 0);

Expand All @@ -254,7 +255,7 @@ static void sys_directx_set_window_title(AL_CONST char *name)
{
HWND allegro_wnd = win_get_window();

do_uconvert(name, U_CURRENT, wnd_title, U_ASCII, WND_TITLE_SIZE);
do_uconvert(name, U_CURRENT, (char*)wnd_title, U_UNICODE, WND_TITLE_SIZE);
SetWindowText(allegro_wnd, wnd_title);
}

Expand Down Expand Up @@ -320,8 +321,8 @@ static void sys_directx_message(AL_CONST char *msg)
msg += uwidth(msg);

MessageBoxW(allegro_wnd,
(unsigned short *)uconvert(msg, U_CURRENT, tmp1, U_UNICODE, ALLEGRO_MESSAGE_SIZE),
(unsigned short *)uconvert(wnd_title, U_ASCII, tmp2, U_UNICODE, sizeof(tmp2)),
(wchar_t*)uconvert(msg, U_CURRENT, tmp1, U_UNICODE, ALLEGRO_MESSAGE_SIZE),
(wchar_t*)uconvert((char*)wnd_title, U_CURRENT, tmp2, U_UNICODE, sizeof(tmp2)),
MB_OK);

_AL_FREE(tmp1);
Expand All @@ -334,7 +335,7 @@ static void sys_directx_message(AL_CONST char *msg)
*/
static void sys_directx_assert(AL_CONST char *msg)
{
OutputDebugString(msg); /* thread safe */
OutputDebugStringA(msg); /* thread safe */
DebugBreak();
}

Expand Down Expand Up @@ -447,7 +448,7 @@ static void sys_directx_yield_timeslice(void)
*/
static int sys_directx_trace_handler(AL_CONST char *msg)
{
OutputDebugString(msg); /* thread safe */
OutputDebugStringA(msg); /* thread safe */
return 0;
}

Expand All @@ -458,25 +459,26 @@ static int sys_directx_trace_handler(AL_CONST char *msg)
* which makes it look as if the application can still have a normal
* main() function.
*/
int _WinMain(void *_main, void *hInst, void *hPrev, char *Cmd, int nShow)
int _WinMain(void* _main, void* hInst, void* hPrev, char* Cmd, int nShow)
{
int (*mainfunc) (int argc, char *argv[]) = (int (*)(int, char *[]))_main;
char *argbuf;
char *cmdline;
char **argv;
int (*mainfunc)(int argc, char *argv[]) = (int (*)(int, char *[]))_main;
wchar_t* argbuf;
wchar_t* cmdline;
wchar_t* arg_w;
char** argv;
int argc;
int argc_max;
int i, q;
int i, j, q;

/* can't use parameter because it doesn't include the executable name */
cmdline = GetCommandLine();
i = strlen(cmdline) + 1;
i = sizeof(wchar_t) * (wcslen(cmdline) + 1);
argbuf = _AL_MALLOC(i);
memcpy(argbuf, cmdline, i);

argc = 0;
argc_max = 64;
argv = _AL_MALLOC(sizeof(char *) * argc_max);
argv = _AL_MALLOC(sizeof(char*) * argc_max);
if (!argv) {
_AL_FREE(argbuf);
return 1;
Expand All @@ -486,19 +488,20 @@ int _WinMain(void *_main, void *hInst, void *hPrev, char *Cmd, int nShow)

/* parse commandline into argc/argv format */
while (argbuf[i]) {
while ((argbuf[i]) && (uisspace(argbuf[i])))
while ((argbuf[i]) && (iswspace(argbuf[i])))
i++;

if (argbuf[i]) {
if ((argbuf[i] == '\'') || (argbuf[i] == '"')) {
if ((argbuf[i] == L'\'') || (argbuf[i] == L'"')) {
q = argbuf[i++];
if (!argbuf[i])
break;
}
else
q = 0;

argv[argc++] = &argbuf[i];
arg_w = argbuf+i;
++argc;

if (argc >= argc_max) {
argc_max += 64;
Expand All @@ -509,23 +512,28 @@ int _WinMain(void *_main, void *hInst, void *hPrev, char *Cmd, int nShow)
}
}

while ((argbuf[i]) && ((q) ? (argbuf[i] != q) : (!uisspace(argbuf[i]))))
while ((argbuf[i]) && ((q) ? (argbuf[i] != q) : (!iswspace(argbuf[i]))))
i++;

if (argbuf[i]) {
argbuf[i] = 0;
i++;
}

argv[argc-1] = convert_widechar_to_utf8(arg_w);
}
}

argv[argc] = NULL;

_AL_FREE(argbuf);

/* call the application entry point */
i = mainfunc(argc, argv);

for (j=0; j<argc; ++j)
_AL_FREE(argv[j]);
_AL_FREE(argv);
_AL_FREE(argbuf);

return i;
}
Expand All @@ -539,9 +547,9 @@ char *win_err_str(long err)
{
static char msg[256];

FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&msg, 0, NULL);
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&msg[0], 0, NULL);

return msg;
}
Expand All @@ -561,5 +569,5 @@ void thread_safe_trace(char *msg,...)
vsprintf(buf, msg, ap);
va_end(ap);

OutputDebugString(buf); /* thread safe */
OutputDebugStringA(buf); /* thread safe */
}
17 changes: 8 additions & 9 deletions src/allegro/src/win/wthread.c
Expand Up @@ -53,21 +53,20 @@ void _win_thread_init(void)
if (first_call) {
first_call = 0;

ole32 = GetModuleHandle("OLE32.DLL");
ole32 = GetModuleHandleA("OLE32.DLL");
if (ole32 != NULL) {
_CoInitializeEx = (_CoInitializeEx_ptr) GetProcAddress(
ole32, "CoInitializeEx");
_CoInitializeEx = (_CoInitializeEx_ptr)GetProcAddress(ole32, "CoInitializeEx");
}
else {
MessageBox(allegro_wnd,
"OLE32.DLL can't be loaded.", "Warning", MB_ICONWARNING + MB_OK);
MessageBoxA(allegro_wnd,
"OLE32.DLL can't be loaded.", "Warning", MB_ICONWARNING + MB_OK);
}

if (_CoInitializeEx == NULL) {
MessageBox(allegro_wnd,
"Microsoft Distributed COM is not installed on this system. If you have problems "
"with this application, please install the DCOM update. You can find it on the "
"Microsoft homepage.", "DCOM not found", MB_ICONWARNING + MB_OK);
MessageBoxA(allegro_wnd,
"Microsoft Distributed COM is not installed on this system. If you have problems "
"with this application, please install the DCOM update. You can find it on the "
"Microsoft homepage.", "DCOM not found", MB_ICONWARNING + MB_OK);
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/allegro/src/win/wwnd.c
Expand Up @@ -40,7 +40,7 @@

/* general */
static HWND allegro_wnd = NULL;
char wnd_title[WND_TITLE_SIZE]; /* ASCII string */
wchar_t wnd_title[WND_TITLE_SIZE]; /* Unicode string title */
int wnd_x = 0;
int wnd_y = 0;
int wnd_width = 0;
Expand All @@ -66,7 +66,7 @@ static BOOL sizing = FALSE;
void (*user_resize_proc)(RESIZE_DISPLAY_EVENT *ev) = NULL;

/* window thread internals */
#define ALLEGRO_WND_CLASS "ASEWindowClass"
#define ALLEGRO_WND_CLASS L"AsepriteWindowClass"
static HANDLE wnd_thread = NULL;
static int old_style = 0;

Expand Down Expand Up @@ -432,7 +432,7 @@ static HWND create_directx_window(void)
wnd_class.cbClsExtra = 0;
wnd_class.cbWndExtra = 0;
wnd_class.hInstance = allegro_inst;
wnd_class.hIcon = LoadIcon(allegro_inst, "allegro_icon");
wnd_class.hIcon = LoadIcon(allegro_inst, L"allegro_icon");
if (!wnd_class.hIcon)
wnd_class.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wnd_class.hCursor = LoadCursor(NULL, IDC_ARROW);
Expand All @@ -450,7 +450,7 @@ static HWND create_directx_window(void)
if (ugetat(fname, -1) == '.')
usetat(fname, -1, 0);

do_uconvert(get_filename(fname), U_CURRENT, wnd_title, U_ASCII, WND_TITLE_SIZE);
do_uconvert(get_filename(fname), U_CURRENT, (char*)wnd_title, U_UNICODE, WND_TITLE_SIZE);

first = 0;
}
Expand Down Expand Up @@ -515,8 +515,8 @@ int init_directx_window(void)
DWORD threadId;

/* setup globals */
msg_call_proc = RegisterWindowMessage("Allegro call proc");
msg_suicide = RegisterWindowMessage("Allegro window suicide");
msg_call_proc = RegisterWindowMessage(L"Allegro call proc");
msg_suicide = RegisterWindowMessage(L"Allegro window suicide");

/* create window thread */
events[0] = CreateEvent(NULL, FALSE, FALSE, NULL); /* acknowledges that thread is up */
Expand Down Expand Up @@ -601,7 +601,7 @@ int adjust_window(int w, int h)
}
else {
/* try to get the height of the window's title bar */
user32_handle = GetModuleHandle("user32");
user32_handle = GetModuleHandle(L"user32");
if (user32_handle) {
get_title_bar_info
= (func)GetProcAddress(user32_handle, "GetTitleBarInfo");
Expand Down
1 change: 1 addition & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -230,4 +230,5 @@ add_library(app-library
util/thmbnail.cpp
webserver.cpp
widget_loader.cpp
xml_document.cpp
xml_exception.cpp)

0 comments on commit 7657461

Please sign in to comment.