--- Frodo4/Src/Prefs_Be.h 2003/07/01 17:51:17 1.2 +++ Frodo4/Src/Prefs_Be.h 2004/01/14 17:26:29 1.5 @@ -1,7 +1,7 @@ /* * Prefs_Be.h - Global preferences, Be specific stuff * - * Frodo (C) 1994-1997,2002-2003 Christian Bauer + * Frodo (C) 1994-1997,2002-2004 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,8 +34,8 @@ const uint32 MSG_OK = 'okok'; const uint32 MSG_CANCEL = 'cncl'; const uint32 MSG_SPRITES_ON = 'spon'; const uint32 MSG_SPRITE_COLLISIONS = 'scol'; -const uint32 MSG_JOYSTICK_1_ON = 'joy1'; -const uint32 MSG_JOYSTICK_2_ON = 'joy2'; +const uint32 MSG_JOYSTICK_1_PORT = 'joy1'; +const uint32 MSG_JOYSTICK_2_PORT = 'joy2'; const uint32 MSG_JOYSTICK_SWAP = 'jswp'; const uint32 MSG_LIMIT_SPEED = 'lmit'; const uint32 MSG_FAST_RESET = 'frst'; @@ -44,10 +44,6 @@ const uint32 MSG_SID_FILTERS = 'filt'; const uint32 MSG_DOUBLE_SCAN = 'dbls'; const uint32 MSG_MAP_SLASH = 'mpsl'; const uint32 MSG_EMUL_1541_PROC = '15pr'; -const uint32 MSG_DRVTYPE_8 = 'drt8'; -const uint32 MSG_DRVTYPE_9 = 'drt9'; -const uint32 MSG_DRVTYPE_10 = 'drt:'; -const uint32 MSG_DRVTYPE_11 = 'drt;'; const uint32 MSG_GETDRIVE_8 = 'gtd8'; const uint32 MSG_GETDRIVE_9 = 'gtd9'; const uint32 MSG_GETDRIVE_10 = 'gtd:'; @@ -82,11 +78,11 @@ public: private: BCheckBox *make_checkbox(BRect frame, char *label, uint32 what, BView *parent); NumberControl *make_number_entry(BRect frame, char *label_text, BView *parent); - BPopUpMenu *make_drvtype_popup(BRect frame, uint32 what, BView *parent); PathControl *make_path_entry(BRect frame, char *label, BView *parent); BPopUpMenu *make_sidtype_popup(BRect frame, char *label_text, uint32 what, BView *parent); BPopUpMenu *make_reusize_popup(BRect frame, char *label_text, uint32 what, BView *parent); BPopUpMenu *make_disptype_popup(BRect frame, char *label_text, uint32 what, BView *parent); + BPopUpMenu *make_joystick_popup(BRect frame, char *label_text, uint32 what, BView *parent); void set_values(void); void get_values(void); void ghost_controls(void); @@ -107,15 +103,14 @@ private: NumberControl *g_cia_cycles; NumberControl *g_floppy_cycles; NumberControl *g_skip_frames; - BPopUpMenu *g_drive_type[4]; PathControl *g_drive_path[4]; BPopUpMenu *g_sid_type; BPopUpMenu *g_reu_size; BPopUpMenu *g_display_type; + BPopUpMenu *g_joystick_1_port; + BPopUpMenu *g_joystick_2_port; BCheckBox *g_sprites_on; BCheckBox *g_sprite_collisions; - BCheckBox *g_joystick_1_on; - BCheckBox *g_joystick_2_on; BCheckBox *g_joystick_swap; BCheckBox *g_limit_speed; BCheckBox *g_fast_reset; @@ -259,7 +254,7 @@ PrefsWindow::PrefsWindow(Prefs *p, bool bar->AddItem(menu); AddChild(bar); SetKeyMenuBar(bar); - int mbar_height = bar->Frame().bottom + 1; + int mbar_height = int(bar->Frame().bottom) + 1; // Resize window to fit menu bar ResizeBy(0, mbar_height); @@ -271,28 +266,28 @@ PrefsWindow::PrefsWindow(Prefs *p, bool top->SetViewColor(fill_color); // Checkboxes - g_sprites_on = make_checkbox(BRect(10, 10, 160, 21), "Sprite display", MSG_SPRITES_ON, top); - g_sprite_collisions = make_checkbox(BRect(10, 25, 160, 36), "Sprite collisions", MSG_SPRITE_COLLISIONS, top); - g_joystick_1_on = make_checkbox(BRect(10, 40, 160, 51), "Joystick on port 1", MSG_JOYSTICK_1_ON, top); - g_joystick_2_on = make_checkbox(BRect(10, 55, 160, 66), "Joystick on port 2", MSG_JOYSTICK_2_ON, top); - g_joystick_swap = make_checkbox(BRect(10, 70, 160, 81), "Swap joysticks", MSG_JOYSTICK_SWAP, top); - g_limit_speed = make_checkbox(BRect(10, 85, 160, 96), "Limit speed", MSG_LIMIT_SPEED, top); - g_fast_reset = make_checkbox(BRect(10, 100, 160, 111), "Fast reset", MSG_FAST_RESET, top); - g_cia_irq_hack = make_checkbox(BRect(10, 115, 160, 126), "Clear CIA ICR on write", MSG_CIA_IRQ_HACK, top); - g_sid_filters = make_checkbox(BRect(10, 130, 160, 141), "SID filters", MSG_SID_FILTERS, top); - g_double_scan = make_checkbox(BRect(10, 145, 160, 156), "Doublescan lines", MSG_DOUBLE_SCAN, top); + g_sprites_on = make_checkbox(BRect(10, 10, 180, 21), "Sprite display", MSG_SPRITES_ON, top); + g_sprite_collisions = make_checkbox(BRect(10, 25, 180, 36), "Sprite collisions", MSG_SPRITE_COLLISIONS, top); + g_limit_speed = make_checkbox(BRect(10, 40, 180, 51), "Limit speed", MSG_LIMIT_SPEED, top); + g_fast_reset = make_checkbox(BRect(10, 55, 180, 66), "Fast reset", MSG_FAST_RESET, top); + g_cia_irq_hack = make_checkbox(BRect(10, 70, 180, 81), "Clear CIA ICR on write", MSG_CIA_IRQ_HACK, top); + g_sid_filters = make_checkbox(BRect(10, 85, 180, 96), "SID filters", MSG_SID_FILTERS, top); + g_double_scan = make_checkbox(BRect(10, 100, 180, 111), "Doublescan lines", MSG_DOUBLE_SCAN, top); + g_joystick_swap = make_checkbox(BRect(10, 115, 180, 126), "Swap joysticks", MSG_JOYSTICK_SWAP, top); + g_joystick_1_port = make_joystick_popup(BRect(10, 130, 180, 145), "Joystick 1", MSG_JOYSTICK_1_PORT, top); + g_joystick_2_port = make_joystick_popup(BRect(10, 150, 180, 165), "Joystick 2", MSG_JOYSTICK_2_PORT, top); // Number entry fields - g_normal_cycles = make_number_entry(BRect(160, 10, 390, 26), "Cycles per line (CPU)", top); - g_bad_line_cycles = make_number_entry(BRect(160, 30, 390, 46), "Cycles per Bad Line (CPU)", top); - g_cia_cycles = make_number_entry(BRect(160, 50, 390, 66), "Cycles per line (CIA)", top); - g_floppy_cycles = make_number_entry(BRect(160, 70, 390, 86), "Cycles per line (1541)", top); - g_skip_frames = make_number_entry(BRect(160, 90, 390, 106), "Draw every n-th frame", top); + g_normal_cycles = make_number_entry(BRect(180, 10, 390, 26), "Cycles per line (CPU)", top); + g_bad_line_cycles = make_number_entry(BRect(180, 30, 390, 46), "Cycles per Bad Line (CPU)", top); + g_cia_cycles = make_number_entry(BRect(180, 50, 390, 66), "Cycles per line (CIA)", top); + g_floppy_cycles = make_number_entry(BRect(180, 70, 390, 86), "Cycles per line (1541)", top); + g_skip_frames = make_number_entry(BRect(180, 90, 390, 106), "Draw every n-th frame", top); // Popup fields - g_display_type = make_disptype_popup(BRect(160, 110, 390, 126), "Display type", MSG_DISPLAY_TYPE, top); - g_sid_type = make_sidtype_popup(BRect(160, 130, 390, 146), "SID emulation type", MSG_SID_TYPE, top); - g_reu_size = make_reusize_popup(BRect(160, 150, 390, 166), "REU size", MSG_REU_SIZE, top); + g_display_type = make_disptype_popup(BRect(180, 110, 390, 126), "Display type", MSG_DISPLAY_TYPE, top); + g_sid_type = make_sidtype_popup(BRect(180, 130, 390, 146), "SID emulation type", MSG_SID_TYPE, top); + g_reu_size = make_reusize_popup(BRect(180, 150, 390, 166), "REU size", MSG_REU_SIZE, top); // Prepare on/off pictures for file panel buttons BView *view = new BView(BRect(0, 0, 19, 15), "", B_FOLLOW_NONE, 0); @@ -346,7 +341,6 @@ PrefsWindow::PrefsWindow(Prefs *p, bool sprintf(str, "%d", i+8); g_drive_path[i] = make_path_entry(BRect(10, 14+i*20, 299, 30+i*20), str, drvbox); drvbox->AddChild(new BPictureButton(BRect(304, 16+i*20, 323, 31+i*20), "", new BPicture(*on), new BPicture(*off), new BMessage(MSG_GETDRIVE_8 + i))); - g_drive_type[i] = make_drvtype_popup(BRect(329, 14+i*20, 373, 30+i*20), MSG_DRVTYPE_8 + i, drvbox); } g_map_slash = make_checkbox(BRect(10, 94, 300, 110), "Map '/'<->'\\' in filenames", MSG_MAP_SLASH, drvbox); @@ -370,6 +364,7 @@ PrefsWindow::PrefsWindow(Prefs *p, bool save_panel->Window()->SetTitle("Frodo: Save preferences"); file_panel = new BFilePanel(B_OPEN_PANEL, &this_messenger, NULL, 0, false, new BMessage(MSG_DRIVE_PANEL_RETURNED)); file_panel->SetPanelDirectory(&AppDirectory); + file_panel->Window()->SetTitle("Frodo: Select disk image or archive file"); dir_panel = new BFilePanel(B_OPEN_PANEL, &this_messenger, NULL, B_DIRECTORY_NODE, false, new BMessage(MSG_DRIVE_PANEL_RETURNED)); dir_panel->SetPanelDirectory(&AppDirectory); dir_panel->Window()->SetTitle("Frodo: Select directory"); @@ -409,24 +404,6 @@ NumberControl *PrefsWindow::make_number_ /* - * Create drive type popup menu - */ - -BPopUpMenu *PrefsWindow::make_drvtype_popup(BRect frame, uint32 what, BView *parent) -{ - BPopUpMenu *popup = new BPopUpMenu("drive_type popup", true, true); - popup->AddItem(new BMenuItem("Dir", new BMessage(what))); - popup->AddItem(new BMenuItem("D64", new BMessage(what))); - popup->AddItem(new BMenuItem("T64", new BMessage(what))); - popup->SetTargetForItems(this); - BMenuField *menu_field = new BMenuField(frame, "drive_type", NULL, popup); - menu_field->SetDivider(0); - parent->AddChild(menu_field); - return popup; -} - - -/* * Create path entry field */ @@ -455,7 +432,7 @@ BPopUpMenu *PrefsWindow::make_disptype_p popup->AddItem(new BMenuItem("Screen", new BMessage(what))); popup->SetTargetForItems(this); BMenuField *menu_field = new BMenuField(frame, "display_type", label_text, popup); - menu_field->SetDivider(frame.Width()-55); + menu_field->SetDivider(frame.Width()-75); menu_field->SetAlignment(B_ALIGN_RIGHT); parent->AddChild(menu_field); return popup; @@ -473,7 +450,7 @@ BPopUpMenu *PrefsWindow::make_sidtype_po popup->AddItem(new BMenuItem("Digital", new BMessage(what))); popup->SetTargetForItems(this); BMenuField *menu_field = new BMenuField(frame, "sid_type", label_text, popup); - menu_field->SetDivider(frame.Width()-55); + menu_field->SetDivider(frame.Width()-75); menu_field->SetAlignment(B_ALIGN_RIGHT); parent->AddChild(menu_field); return popup; @@ -493,7 +470,28 @@ BPopUpMenu *PrefsWindow::make_reusize_po popup->AddItem(new BMenuItem("512K", new BMessage(what))); popup->SetTargetForItems(this); BMenuField *menu_field = new BMenuField(frame, "reu_size", label_text, popup); - menu_field->SetDivider(frame.Width()-55); + menu_field->SetDivider(frame.Width()-75); + menu_field->SetAlignment(B_ALIGN_RIGHT); + parent->AddChild(menu_field); + return popup; +} + + +/* + * Create joystick port popup + */ + +BPopUpMenu *PrefsWindow::make_joystick_popup(BRect frame, char *label_text, uint32 what, BView *parent) +{ + BPopUpMenu *popup = new BPopUpMenu("joystick popup", true, true); + popup->AddItem(new BMenuItem("None", new BMessage(what))); + popup->AddItem(new BMenuItem("Joystick Port 1", new BMessage(what))); + popup->AddItem(new BMenuItem("Joystick Port 2", new BMessage(what))); + popup->AddItem(new BMenuItem("GeekPort A", new BMessage(what))); + popup->AddItem(new BMenuItem("GeekPort B", new BMessage(what))); + popup->SetTargetForItems(this); + BMenuField *menu_field = new BMenuField(frame, "joystick", label_text, popup); + menu_field->SetDivider(60); menu_field->SetAlignment(B_ALIGN_RIGHT); parent->AddChild(menu_field); return popup; @@ -514,10 +512,8 @@ void PrefsWindow::set_values(void) g_floppy_cycles->SetValue(prefs->FloppyCycles); g_skip_frames->SetValue(prefs->SkipFrames); - for (int i=0; i<4; i++) { - g_drive_type[i]->ItemAt(prefs->DriveType[i])->SetMarked(true); + for (int i=0; i<4; i++) g_drive_path[i]->SetText(prefs->DrivePath[i]); - } g_sid_type->ItemAt(prefs->SIDType)->SetMarked(true); g_reu_size->ItemAt(prefs->REUSize)->SetMarked(true); @@ -525,8 +521,8 @@ void PrefsWindow::set_values(void) g_sprites_on->SetValue(prefs->SpritesOn ? B_CONTROL_ON : B_CONTROL_OFF); g_sprite_collisions->SetValue(prefs->SpriteCollisions ? B_CONTROL_ON : B_CONTROL_OFF); - g_joystick_1_on->SetValue(prefs->Joystick1On ? B_CONTROL_ON : B_CONTROL_OFF); - g_joystick_2_on->SetValue(prefs->Joystick2On ? B_CONTROL_ON : B_CONTROL_OFF); + g_joystick_1_port->ItemAt(prefs->Joystick1Port)->SetMarked(true); + g_joystick_2_port->ItemAt(prefs->Joystick2Port)->SetMarked(true); g_joystick_swap->SetValue(prefs->JoystickSwap ? B_CONTROL_ON : B_CONTROL_OFF); g_limit_speed->SetValue(prefs->LimitSpeed ? B_CONTROL_ON : B_CONTROL_OFF); g_fast_reset->SetValue(prefs->FastReset ? B_CONTROL_ON : B_CONTROL_OFF); @@ -615,12 +611,12 @@ void PrefsWindow::MessageReceived(BMessa prefs->SpriteCollisions = !prefs->SpriteCollisions; break; - case MSG_JOYSTICK_1_ON: - prefs->Joystick1On = !prefs->Joystick1On; + case MSG_JOYSTICK_1_PORT: + prefs->Joystick1Port = msg->FindInt32("index"); break; - case MSG_JOYSTICK_2_ON: - prefs->Joystick2On = !prefs->Joystick2On; + case MSG_JOYSTICK_2_PORT: + prefs->Joystick2Port = msg->FindInt32("index"); break; case MSG_JOYSTICK_SWAP: @@ -668,28 +664,15 @@ void PrefsWindow::MessageReceived(BMessa prefs->Emul1541Proc = !prefs->Emul1541Proc; break; - case MSG_DRVTYPE_8: - case MSG_DRVTYPE_9: - case MSG_DRVTYPE_10: - case MSG_DRVTYPE_11: - prefs->DriveType[msg->what & 3] = msg->FindInt32("index"); - break; - case MSG_GETDRIVE_8: case MSG_GETDRIVE_9: case MSG_GETDRIVE_10: case MSG_GETDRIVE_11: panel_drive_num = msg->what & 3; - file_panel->Hide(); - dir_panel->Hide(); - if (prefs->DriveType[panel_drive_num] == DRVTYPE_D64) { - file_panel->Window()->SetTitle("Frodo: Select disk image file"); - file_panel->Show(); - } else if (prefs->DriveType[panel_drive_num] == DRVTYPE_T64) { - file_panel->Window()->SetTitle("Frodo: Select archive file"); - file_panel->Show(); - } else - dir_panel->Show(); +// file_panel->Hide(); +// dir_panel->Hide(); + file_panel->Show(); +// dir_panel->Show(); break; case MSG_DRIVE_PANEL_RETURNED: { // Drive path file panel returned @@ -775,7 +758,7 @@ bool PrefsWindow::FilterKeyDown(uint32 * if (*aChar == B_ESCAPE) { // Flash Cancel button g_cancel->SetValue(B_CONTROL_ON); - snooze(100000.0); + snooze(100000); PostMessage(MSG_CANCEL); } return true;