Skip to content

Commit

Permalink
Replace crashy clicktab with startup mode selection for 3.X users
Browse files Browse the repository at this point in the history
  • Loading branch information
sacredbanana committed Jan 31, 2024
1 parent b24e6b7 commit 79ec815
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 37 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## 1.4.2 (2024-01-31)
- Replaced clicktabs for AmigaOS 3.X since the version is too old and will crash. 3.X users can select the mode at startup.

## 1.4.1 (2024-01-22)
- Fixed bug where the prompt textbox remains in a readonly state when switching from image mode to chat mode

Expand Down
5 changes: 5 additions & 0 deletions bundle/AmigaGPT/AmigaGPT.guide
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,12 @@ Training data: Up to Sep 2021
@node changelog "Changelog"
@{b}Changelog@{ub}

@{b}1.4.2 (2024-01-31)@{ub}

- Replaced clicktabs for AmigaOS 3.X since the version is too old and will crash. 3.X users can select the mode at startup.

@{b}1.4.1 (2024-01-22)@{ub}

- Fixed bug where the prompt textbox remains in a readonly state when switching from image mode to chat mode

@{b}1.4.0 (2024-01-21)@{ub}
Expand Down
28 changes: 19 additions & 9 deletions bundle/AmigaGPT/AmigaGPT.readme
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Kurz: App zum Chatten mit ChatGPT
Author: Cameron Armstrong (Nightfox) <cameronscottarmstrong@gmail.com>
Uploader: Cameron Armstrong (Nightfox) <cameronscottarmstrong@gmail.com>
Type: util/misc
Version: 1.4.1
Version: 1.4.2
Architecture: m68k-amigaos >= 3.9; ppc-amigaos
Requires: AmigaOS 3.9+/68020+ util/libs/AmiSSL-5.9-OS3.lha
Replaces: util/misc/AmigaGPT.lha

AmigaGPT is a text and image generation program that runs on the classic AmigaOS.
Utilising the power of the OpenAI's GPT-3 and GPT-4 architectures, this
program brings state-of-the-art language modeling to your Amiga computer.
AmigaGPT is a text and image generation program that runs on the classic
AmigaOS. Utilising the power of the OpenAI's GPT-3 and GPT-4 architectures,
this program brings state-of-the-art language modeling to your Amiga computer.

Features:
- Generates text based on input prompts
Expand All @@ -23,7 +23,7 @@ Requirements:
- OCS/ECS/AGA Amiga
- Motorola 68020 or higher CPU or PPC for AmigaOS 4
- AmigaOS 3.9 and AmigaOS 3.X (included in Amiga Forever) supported but
3.2 or higher recommended. AmigaOS 4.1 version also included.
3.2 or higher required for best experience. AmigaOS 4.1 version also included.
- AmiSSL 5.9 or higher (http://aminet.net/util/libs/AmiSSL-5.9-OS3.lha)
- Internet access using a TCP/IP stack such as Roadshow
(http://roadshow.apc-tcp.de/index-en.php)
Expand Down Expand Up @@ -208,19 +208,28 @@ Special Thanks:
https://www.hyperion-entertainment.com

Changelog:
------------------
1.4.2 (2024-01-31)
- Replaced clicktabs for AmigaOS 3.X since the version is too old and will
crash. 3.X users can select the mode at startup.
------------------

------------------
1.4.1 (2024-01-22)
- Fixed bug where the prompt textbox remains in a readonly state when switching from image mode to chat mode
- Fixed bug where the prompt textbox remains in a readonly state when
switching from image mode to chat mode
------------------

------------------
1.4.0 (2024-01-21)
------------------
- AI image generation! Switch between chat and image generation mode by clicking the tabs at the top of the screen
- AI image generation! Switch between chat and image generation mode by
clicking the tabs at the top of the screen
- Colour tweaks
- Status bar shows more information and colours
- About screen can now be dismissed with any key press or mouse click
- The OpenAI API key requester now populates with the existing key if it exists so you can more easily find and fix typos in the key
- The OpenAI API key requester now populates with the existing key if it
exists so you can more easily find and fix typos in the key
- Added the ability to set the chat system (new "Chat System" menu item)
- Fix crash when having a conversation consisting of a few messages

Expand Down Expand Up @@ -259,7 +268,8 @@ Changelog:
------------------
1.0.1 (2023-06-24)
------------------
- After setting UI font, the font is now applied fully without needing to restart the app
- After setting UI font, the font is now applied fully without needing
to restart the app

----------------
1.0 (2023-06-17)
Expand Down
128 changes: 102 additions & 26 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#define OPEN_LARGE_IMAGE_BUTTON_ID 17
#define OPEN_ORIGINAL_IMAGE_BUTTON_ID 18
#define SAVE_COPY_BUTTON_ID 19
#define MODE_SELECT_RADIO_BUTTON_ID 20

#define MODE_SELECTION_TAB_CHAT_ID 0
#define MODE_SELECTION_TAB_IMAGE_GENERATION_ID 1
Expand Down Expand Up @@ -200,6 +201,8 @@ static Object *saveCopyButton;
static Object *imageHistoryButtonsLayout;
static struct Screen *screen;
static BOOL isPublicScreen;
static BOOL isAmigaOS3X;
static LONG selectedMode;
static WORD pens[32+1];
static LONG textEdtorColorMap[] = {5,3,6,3,6,6,4,0,1,6,6,6,6,6,6,6};
static LONG sendMessageButtonPen;
Expand Down Expand Up @@ -305,7 +308,7 @@ static STRPTR getMessageContentFromJson(struct json_object *json, BOOL stream);
static void formatText(STRPTR unformattedText);
static void sendChatMessage();
static void closeGUILibraries();
static LONG selectScreen();
static LONG openStartupOptions();
static void refreshOpenAIMenuItems();
static void refreshSpeechMenuItems();
static struct MinList* newConversation();
Expand Down Expand Up @@ -545,6 +548,8 @@ LONG openGUILibraries() {
}
#endif

isAmigaOS3X = ClickTabBase->lib_Version < 45;

#ifdef __AMIGAOS3__
if ((RadioButtonBase = OpenLibrary("gadgets/radiobutton.gadget", 44)) == NULL) {
printf("Could not open radiobutton.gadget\n");
Expand Down Expand Up @@ -766,7 +771,7 @@ LONG initVideo() {
return RETURN_ERROR;
}

if (selectScreen() == RETURN_ERROR)
if (openStartupOptions() == RETURN_ERROR)
return RETURN_ERROR;

modeSelectionTabList = AllocVec(sizeof(struct List), MEMF_CLEAR);
Expand Down Expand Up @@ -1200,12 +1205,29 @@ LONG initVideo() {
return RETURN_ERROR;
}

Object *layoutToOpen;
if (isAmigaOS3X) {
switch (selectedMode) {
case MODE_SELECTION_TAB_CHAT_ID:
layoutToOpen = chatModeLayout;
break;
case MODE_SELECTION_TAB_IMAGE_GENERATION_ID:
layoutToOpen = imageGenerationModeLayout;
break;
default:
layoutToOpen = chatModeLayout;
break;
}
} else {
layoutToOpen = modeClickTab;
}

if ((mainLayout = NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_DeferLayout, TRUE,
LAYOUT_SpaceInner, TRUE,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_AddChild, modeClickTab,
LAYOUT_AddChild, layoutToOpen,
TAG_DONE)) == NULL) {
printf("Could not create main layout\n");
return RETURN_ERROR;
Expand Down Expand Up @@ -1259,7 +1281,8 @@ LONG initVideo() {

if (!isPublicScreen) {
SetGadgetAttrs(textInputTextEditor, mainWindow, NULL, GA_TEXTEDITOR_ColorMap, &textEdtorColorMap, TAG_DONE);
SetGadgetAttrs(chatOutputTextEditor, mainWindow, NULL, GA_TEXTEDITOR_ColorMap, &textEdtorColorMap, TAG_DONE);
if (!isAmigaOS3X || selectedMode == MODE_SELECTION_TAB_CHAT_ID)
SetGadgetAttrs(chatOutputTextEditor, mainWindow, NULL, GA_TEXTEDITOR_ColorMap, &textEdtorColorMap, TAG_DONE);
}

refreshOpenAIMenuItems();
Expand All @@ -1270,7 +1293,11 @@ LONG initVideo() {

updateStatusBar("Ready", 5);

ActivateLayoutGadget(chatModeLayout, mainWindow, NULL, textInputTextEditor);
if (!isAmigaOS3X || selectedMode == MODE_SELECTION_TAB_CHAT_ID) {
ActivateLayoutGadget(chatModeLayout, mainWindow, NULL, textInputTextEditor);
} else {
ActivateLayoutGadget(imageGenerationModeLayout, mainWindow, NULL, textInputTextEditor);
}

return RETURN_OK;
}
Expand All @@ -1287,11 +1314,11 @@ void updateStatusBar(CONST_STRPTR message, const ULONG pen) {
}

/**
* Display a requester for the screen the application should open on
* Display a requester for the screen the application should open on and the mode to run in (if AmigaOS 3.X)
* @return RETURN_OK on success, RETURN_ERROR on failure
**/
static LONG selectScreen() {
Object *screenSelectRadioButton, *selectScreenOkButton, *screenSelectLayout, *screenSelectWindowObject;
static LONG openStartupOptions() {
Object *screenSelectRadioButton, *modeSelectRadioButton, *startupOptionsOkButton, *screenSelectLayout, *startupOptionsWindowObject, *startupOptionsLayout, *modeSelectLayout = NULL;
struct Window *screenSelectWindow;
struct ScreenModeRequester *screenModeRequester;
screen = LockPubScreen("Workbench");
Expand All @@ -1303,7 +1330,7 @@ static LONG selectScreen() {
screenFont.ta_Flags = config.uiFontFlags;
}

STRPTR radioButtonOptions[] = {
CONST_STRPTR radioButtonOptions[] = {
"New screen",
"Open in Workbench",
NULL
Expand All @@ -1312,7 +1339,7 @@ static LONG selectScreen() {
if ((screenSelectRadioButton = NewObject(RADIOBUTTON_GetClass(), NULL,
GA_ID, SCREEN_SELECT_RADIO_BUTTON_ID,
GA_Width, 100,
GA_Height, 30,
GA_Height, ClickTabBase->lib_Version > 45 ? 100 : 50,
BUTTON_Justification, BCJ_CENTER,
GA_Text, (ULONG)radioButtonOptions,
GA_RelVerify, TRUE,
Expand All @@ -1322,7 +1349,7 @@ static LONG selectScreen() {
return RETURN_ERROR;
}

if ((selectScreenOkButton = NewObject(BUTTON_GetClass(), NULL,
if ((startupOptionsOkButton = NewObject(BUTTON_GetClass(), NULL,
GA_ID, SCREEN_SELECT_OK_BUTTON_ID,
GA_Width, 100,
GA_Height, 30,
Expand All @@ -1331,49 +1358,94 @@ static LONG selectScreen() {
GA_RelVerify, TRUE,
ICA_TARGET, ICTARGET_IDCMP,
TAG_DONE)) == NULL) {
printf("Could not create selectScreenOkButton\n");
printf("Could not create startupOptionsOkButton\n");
return RETURN_ERROR;
}

if ((screenSelectLayout = NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_DeferLayout, TRUE,
LAYOUT_SpaceInner, TRUE,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_BottomSpacing, 10,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_Label, "Select a screen to open the window in:",
LAYOUT_Label, "Screen to open:",
LAYOUT_LabelPlace, BVJ_TOP_CENTER,
LAYOUT_BevelStyle, BVS_GROUP,
LAYOUT_AddChild, screenSelectRadioButton,
CHILD_WeightedHeight, 80,
LAYOUT_AddChild, selectScreenOkButton,
CHILD_MaxHeight, 20,
CHILD_MaxWidth, 50,
CHILD_WeightedHeight, 20,
TAG_DONE)) == NULL) {
printf("Could not create screenSelectLayout\n");
return RETURN_ERROR;
}

if ((screenSelectWindowObject = NewObject(WINDOW_GetClass(), NULL,
if (isAmigaOS3X) {
CONST_STRPTR radioButtonOptions[] = {
"Chat",
"Image Generation",
NULL
};

if ((modeSelectRadioButton = NewObject(RADIOBUTTON_GetClass(), NULL,
GA_ID, MODE_SELECT_RADIO_BUTTON_ID,
GA_Width, 100,
BUTTON_Justification, BCJ_CENTER,
GA_Text, (ULONG)radioButtonOptions,
GA_RelVerify, TRUE,
ICA_TARGET, ICTARGET_IDCMP,
TAG_DONE)) == NULL) {
printf("Could not create modeSelectRadioButton\n");
return RETURN_ERROR;
}

if ((modeSelectLayout = NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceInner, TRUE,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_BottomSpacing, 10,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_Label, "Mode:",
LAYOUT_LabelPlace, BVJ_TOP_CENTER,
LAYOUT_BevelStyle, BVS_GROUP,
LAYOUT_AddChild, modeSelectRadioButton,
TAG_DONE)) == NULL) {
printf("Could not create modeSelectLayout\n");
return RETURN_ERROR;
}
}

if ((startupOptionsLayout = NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_DeferLayout, TRUE,
LAYOUT_SpaceInner, TRUE,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_BottomSpacing, 10,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_AddChild, screenSelectLayout,
isAmigaOS3X ? LAYOUT_AddChild : TAG_SKIP, modeSelectLayout,
LAYOUT_AddChild, startupOptionsOkButton,
TAG_DONE)) == NULL) {
printf("Could not create startupOptionsLayout\n");
return RETURN_ERROR;
}

if ((startupOptionsWindowObject = NewObject(WINDOW_GetClass(), NULL,
WINDOW_Position, WPOS_CENTERSCREEN,
WA_Activate, TRUE,
WA_Title, "Screen Select",
WA_Title, "Startup Options",
WA_Width, 200,
WA_Height, 50,
WA_CloseGadget, FALSE,
WINDOW_SharedPort, NULL,
WINDOW_Position, WPOS_CENTERSCREEN,
WA_DragBar, TRUE,
WINDOW_Layout, screenSelectLayout,
WINDOW_Layout, startupOptionsLayout,
WA_IDCMP, IDCMP_GADGETUP,
WA_CustomScreen, screen,
TAG_DONE)) == NULL) {
printf("Could not create screenSelectWindow object\n");
return RETURN_ERROR;
}

if ((screenSelectWindow = (struct Window *)DoMethod(screenSelectWindowObject, WM_OPEN, NULL)) == NULL) {
if ((screenSelectWindow = (struct Window *)DoMethod(startupOptionsWindowObject, WM_OPEN, NULL)) == NULL) {
printf("Could not open screenSelectWindow\n");
return RETURN_ERROR;
}
Expand All @@ -1382,16 +1454,20 @@ static LONG selectScreen() {
ULONG signalMask, winSignal, signals, result;
WORD code;

GetAttr(WINDOW_SigMask, screenSelectWindowObject, &winSignal);
GetAttr(WINDOW_SigMask, startupOptionsWindowObject, &winSignal);
signalMask = winSignal;
while (!done) {
signals = Wait(signalMask);
while ((result = DoMethod(screenSelectWindowObject, WM_HANDLEINPUT, &code)) != WMHI_LASTMSG) {
while ((result = DoMethod(startupOptionsWindowObject, WM_HANDLEINPUT, &code)) != WMHI_LASTMSG) {
switch (result & WMHI_CLASSMASK) {
case WMHI_GADGETUP:
switch (result & WMHI_GADGETMASK) {
case SCREEN_SELECT_OK_BUTTON_ID:
{
if (isAmigaOS3X) {
GetAttr(RADIOBUTTON_Selected, modeSelectRadioButton, &selectedMode);
}

LONG selectedRadioButton;
GetAttr(RADIOBUTTON_Selected, screenSelectRadioButton, &selectedRadioButton);

Expand Down Expand Up @@ -1467,7 +1543,7 @@ static LONG selectScreen() {
}
}

DoMethod(screenSelectWindowObject, WM_CLOSE);
DoMethod(startupOptionsWindowObject, WM_CLOSE);

return RETURN_OK;
}
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define APP_VERSION "1.4.1"
#define BUILD_NUMBER "2609"
#define APP_VERSION "1.4.2"
#define BUILD_NUMBER "2634"
#define APP_NAME "AmigaGPT"

0 comments on commit 79ec815

Please sign in to comment.