mirror of
https://github.com/CamHenlin/MessagesForMacintosh.git
synced 2024-06-12 22:29:30 +00:00
Compare commits
2 Commits
0158121fe1
...
ef29cf88e1
Author | SHA1 | Date | |
---|---|---|---|
|
ef29cf88e1 | ||
|
3985d86486 |
BIN
dist/MessagesForMacintosh.dsk
vendored
BIN
dist/MessagesForMacintosh.dsk
vendored
Binary file not shown.
BIN
dist/MessagesForMacintosh.zip
vendored
BIN
dist/MessagesForMacintosh.zip
vendored
Binary file not shown.
26
mac_main.c
26
mac_main.c
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
// #define MAC_APP_DEBUGGING
|
// #define MAC_APP_DEBUGGING
|
||||||
// #define PROFILING 1
|
// #define PROFILING 1
|
||||||
#define DEBUG_FUNCTION_CALLS
|
// #define DEBUG_FUNCTION_CALLS
|
||||||
#ifdef PROFILING
|
#ifdef PROFILING
|
||||||
|
|
||||||
OSErr writeSerialPortProfile(const char* str)
|
OSErr writeSerialPortProfile(const char* str)
|
||||||
|
@ -182,7 +182,6 @@ void EventLoop(struct nk_context *ctx)
|
||||||
int lastMouseVPos = 0;
|
int lastMouseVPos = 0;
|
||||||
int lastUpdatedTickCountMessagesInChat = 0;
|
int lastUpdatedTickCountMessagesInChat = 0;
|
||||||
int lastUpdatedTickCountChatCounts = 0;
|
int lastUpdatedTickCountChatCounts = 0;
|
||||||
Boolean gotNewMessages = false;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
|
@ -198,16 +197,11 @@ void EventLoop(struct nk_context *ctx)
|
||||||
ShowCursor();
|
ShowCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
gotNewMessages = false;
|
|
||||||
|
|
||||||
// check for new stuff every 10 sec?
|
// check for new stuff every 10 sec?
|
||||||
// note! this is used by some of the functionality in our nuklear_app to trigger
|
// note! this is used by some of the functionality in our nuklear_app to trigger
|
||||||
// new chat lookups
|
// new chat lookups
|
||||||
if (TickCount() - lastUpdatedTickCountMessagesInChat > 600) {
|
if (TickCount() - lastUpdatedTickCountMessagesInChat > 300) {
|
||||||
|
|
||||||
gotNewMessages = true;
|
|
||||||
|
|
||||||
// writeSerialPortDebug(boutRefNum, "update by tick count");
|
|
||||||
lastUpdatedTickCountMessagesInChat = TickCount();
|
lastUpdatedTickCountMessagesInChat = TickCount();
|
||||||
|
|
||||||
if (strcmp(activeChat, "no active chat")) {
|
if (strcmp(activeChat, "no active chat")) {
|
||||||
|
@ -218,8 +212,8 @@ void EventLoop(struct nk_context *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should be out of sync with the counter above it so that we dont end up making
|
// this should be out of sync with the counter above it so that we dont end up making
|
||||||
// two coprocessor calls on one event loop iteration
|
// two coprocessor calls on one event loop iteratio
|
||||||
if (!gotNewMessages && TickCount() - lastUpdatedTickCountChatCounts > 300) {
|
if (TickCount() - lastUpdatedTickCountChatCounts > 600) {
|
||||||
|
|
||||||
// writeSerialPortDebug(boutRefNum, "update by tick count");
|
// writeSerialPortDebug(boutRefNum, "update by tick count");
|
||||||
lastUpdatedTickCountChatCounts = TickCount();
|
lastUpdatedTickCountChatCounts = TickCount();
|
||||||
|
@ -319,18 +313,6 @@ void EventLoop(struct nk_context *ctx)
|
||||||
// only re-render if there is an event, prevents screen flickering, speeds up app
|
// only re-render if there is an event, prevents screen flickering, speeds up app
|
||||||
if (beganInput || firstOrMouseMove || forceRedraw) {
|
if (beganInput || firstOrMouseMove || forceRedraw) {
|
||||||
|
|
||||||
if (beganInput) {
|
|
||||||
writeSerialPortDebug(boutRefNum, "beganInput");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (beganInput) {
|
|
||||||
writeSerialPortDebug(boutRefNum, "beganInput");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (forceRedraw) {
|
|
||||||
writeSerialPortDebug(boutRefNum, "forceRedraw");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PROFILING
|
#ifdef PROFILING
|
||||||
PROFILE_START("nk_input_end");
|
PROFILE_START("nk_input_end");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -181,14 +181,16 @@ void sendMessage() {
|
||||||
|
|
||||||
memset(&box_input_buffer, '\0', 2048);
|
memset(&box_input_buffer, '\0', 2048);
|
||||||
box_input_len = 0;
|
box_input_len = 0;
|
||||||
refreshNuklearApp(1);
|
|
||||||
|
// this was an attempt to get the text in the textbox to go away... doesn't really work for a few more redraws
|
||||||
|
// so actually just makes things slower:
|
||||||
|
// refreshNuklearApp(1);
|
||||||
|
|
||||||
callFunctionOnCoprocessor("sendMessage", output, jsFunctionResponse);
|
callFunctionOnCoprocessor("sendMessage", output, jsFunctionResponse);
|
||||||
|
|
||||||
getMessagesFromjsFunctionResponse();
|
getMessagesFromjsFunctionResponse();
|
||||||
|
|
||||||
forceRedraw = 2;
|
forceRedraw = 3;
|
||||||
firstOrMouseMove = true;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -206,8 +208,9 @@ void getChats() {
|
||||||
callFunctionOnCoprocessor("getChats", "", jsFunctionResponse);
|
callFunctionOnCoprocessor("getChats", "", jsFunctionResponse);
|
||||||
|
|
||||||
char *token = (char *)strtokm(jsFunctionResponse, ",");
|
char *token = (char *)strtokm(jsFunctionResponse, ",");
|
||||||
// loop through the string to extract all other tokens
|
|
||||||
while (token != NULL) {
|
while (token != NULL) {
|
||||||
|
|
||||||
writeSerialPortDebug(boutRefNum, token);
|
writeSerialPortDebug(boutRefNum, token);
|
||||||
sprintf(chatFriendlyNames[chatFriendlyNamesCounter++], "%s", token);
|
sprintf(chatFriendlyNames[chatFriendlyNamesCounter++], "%s", token);
|
||||||
token = (char *)strtokm(NULL, ",");
|
token = (char *)strtokm(NULL, ",");
|
||||||
|
@ -238,7 +241,7 @@ void sendIPAddressToCoprocessor() {
|
||||||
|
|
||||||
// set up function to get messages in current chat
|
// set up function to get messages in current chat
|
||||||
// limit to recent messages
|
// limit to recent messages
|
||||||
// figure out pagination?? button on the top that says "get previous chats"?
|
// figure out pagination?? button on the top that says "get previous chats"?, TODO
|
||||||
void getMessages(char *thread, int page) {
|
void getMessages(char *thread, int page) {
|
||||||
|
|
||||||
#ifdef DEBUG_FUNCTION_CALLS
|
#ifdef DEBUG_FUNCTION_CALLS
|
||||||
|
@ -284,12 +287,18 @@ void getChatCounts() {
|
||||||
writeSerialPortDebug(boutRefNum, chatCountFunctionResponse);
|
writeSerialPortDebug(boutRefNum, chatCountFunctionResponse);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (strcmp(chatCountFunctionResponse, previousChatCountFunctionResponse)) {
|
// bail out if the responses ARE equal
|
||||||
|
if (!strcmp(chatCountFunctionResponse, previousChatCountFunctionResponse)) {
|
||||||
|
|
||||||
#ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING
|
writeSerialPortDebug(boutRefNum, "no need to update current chat count");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//#ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING
|
||||||
writeSerialPortDebug(boutRefNum, "update current chat count");
|
writeSerialPortDebug(boutRefNum, "update current chat count");
|
||||||
writeSerialPortDebug(boutRefNum, chatCountFunctionResponse);
|
writeSerialPortDebug(boutRefNum, chatCountFunctionResponse);
|
||||||
#endif
|
writeSerialPortDebug(boutRefNum, previousChatCountFunctionResponse);
|
||||||
|
//#endif
|
||||||
|
|
||||||
SysBeep(1);
|
SysBeep(1);
|
||||||
|
|
||||||
|
@ -418,10 +427,6 @@ void getChatCounts() {
|
||||||
|
|
||||||
strcpy(previousChatCountFunctionResponse, chatCountFunctionResponse);
|
strcpy(previousChatCountFunctionResponse, chatCountFunctionResponse);
|
||||||
forceRedraw = 3;
|
forceRedraw = 3;
|
||||||
} else {
|
|
||||||
|
|
||||||
writeSerialPortDebug(boutRefNum, "no need to update current chat count");
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -446,9 +451,6 @@ void getHasNewMessagesInChat(char *thread) {
|
||||||
writeSerialPortDebug(boutRefNum, "update current chat");
|
writeSerialPortDebug(boutRefNum, "update current chat");
|
||||||
SysBeep(1);
|
SysBeep(1);
|
||||||
getMessages(thread, 0);
|
getMessages(thread, 0);
|
||||||
|
|
||||||
// force redraw
|
|
||||||
forceRedraw = 3;
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
writeSerialPortDebug(boutRefNum, "do not update current chat");
|
writeSerialPortDebug(boutRefNum, "do not update current chat");
|
||||||
|
|
|
@ -451,16 +451,16 @@ NK_API NkQuickDrawFont* nk_quickdraw_font_create_from_file() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// used for bounds checking
|
// used for bounds checking
|
||||||
int mostLeft = 1;
|
int mostLeft = WINDOW_WIDTH;
|
||||||
int mostBottom = 1;
|
int mostBottom = 1;
|
||||||
int mostTop = WINDOW_HEIGHT;
|
int mostTop = WINDOW_HEIGHT;
|
||||||
int mostRight = WINDOW_WIDTH;
|
int mostRight = 1;
|
||||||
|
|
||||||
void updateBounds(int top, int bottom, int left, int right) {
|
void updateBounds(int top, int bottom, int left, int right) {
|
||||||
|
|
||||||
#ifdef DEBUG_FUNCTION_CALLS
|
// #ifdef DEBUG_FUNCTION_CALLS
|
||||||
writeSerialPortDebug(boutRefNum, "DEBUG_FUNCTION_CALLS: updateBounds");
|
writeSerialPortDebug(boutRefNum, "DEBUG_FUNCTION_CALLS: updateBounds");
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
if (left < mostLeft) {
|
if (left < mostLeft) {
|
||||||
|
|
||||||
|
@ -481,6 +481,7 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||||
|
|
||||||
mostBottom = bottom;
|
mostBottom = bottom;
|
||||||
}
|
}
|
||||||
|
writeSerialPortDebug(boutRefNum, "END OF DEBUG_FUNCTION_CALLS: updateBounds");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef COMMAND_CACHING
|
#ifdef COMMAND_CACHING
|
||||||
|
@ -1181,10 +1182,10 @@ NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
|
||||||
|
|
||||||
CopyBits(&gMainOffScreen.bits->portBits, &window->portBits, &quickDrawRectangle, &quickDrawRectangle, srcCopy, 0L);
|
CopyBits(&gMainOffScreen.bits->portBits, &window->portBits, &quickDrawRectangle, &quickDrawRectangle, srcCopy, 0L);
|
||||||
|
|
||||||
mostLeft = 1;
|
mostLeft = WINDOW_WIDTH;
|
||||||
mostBottom = 1;
|
mostBottom = 1;
|
||||||
mostTop = WINDOW_HEIGHT;
|
mostTop = WINDOW_HEIGHT;
|
||||||
mostRight = WINDOW_WIDTH;
|
mostRight = 1;
|
||||||
|
|
||||||
#ifdef PROFILING
|
#ifdef PROFILING
|
||||||
PROFILE_END("copy bits");
|
PROFILE_END("copy bits");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user