Permalink
Browse files

Separate key init from tab layout.

Make the tab a subobject of the module
lvalue accessors whee!
  • Loading branch information...
1 parent f028194 commit 1a05bd44b5abd35bb6e6cac77372b7048614ba24 @emersonrp committed Jul 9, 2010
Showing with 330 additions and 256 deletions.
  1. +36 −27 Profile.pm
  2. +18 −12 Profile/FPSDisplay.pm
  3. +37 −30 Profile/General.pm
  4. +26 −18 Profile/InspirationPopper.pm
  5. +29 −22 Profile/Mastermind.pm
  6. +32 −26 Profile/PetSel.pm
  7. +20 −10 Profile/ProfileTab.pm
  8. +89 −81 Profile/SoD.pm
  9. +21 −15 Profile/TeamSel.pm
  10. +22 −15 Profile/TypingMsg.pm
View
@@ -34,47 +34,56 @@ sub new {
# TODO -- here's where we'd load a profile from a file or something.
# Add the individual tabs, in order.
- my $tab;
- $tab = Profile::General->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ my $module;
+ $module = Profile::General->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::SoD->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::SoD->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::BufferBinds->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::BufferBinds->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::ComplexBinds->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::ComplexBinds->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::CustomBinds->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::CustomBinds->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::FPSDisplay->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::FPSDisplay->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::InspirationPopper->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::InspirationPopper->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::Mastermind->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::Mastermind->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::PetSel->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::PetSel->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::SimpleBinds->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::SimpleBinds->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::TeamSel->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::TeamSel->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::TeamSel2->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::TeamSel2->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
- $tab = Profile::TypingMsg->new($self);
- $self->AddPage( $tab, $tab->{'TabTitle'} );
+ $module = Profile::TypingMsg->new($self);
+ $self->AddPage( $module->Tab, $module->TabTitle );
return $self;
}
+# this is the little callback the modules use to register themselves.
+sub AddModule {
+ my $self = shift;
+ my $module = shift;
+
+ no strict 'refs';
+ *{ $module } = sub : lvalue { shift->{$module} };
+
+}
1;
View
@@ -9,33 +9,39 @@ use Wx qw( :everything );
use Utility qw(id);
-sub new {
+sub InitKeys {
+ my $self = shift;
- my ($class, $profile) = @_;
+ $self->Profile->AddModule('FPS');
- my $self = $class->SUPER::new($profile);
-
- $self->{'TabTitle'} = "FPS / Netgraph";
-
- $profile->{'FPS'} ||= {
+ $self->Profile->FPS ||= {
Enable => 1,
Bindkey => "P",
};
- my $FPS = $profile->{'FPS'};
+}
+
+sub FillTab {
+
+ my $self = shift;
+
+ $self->TabTitle = "FPS / Netgraph";
+
+ my $FPS = $self->Profile->FPS;
+ my $Tab = $self->Tab;
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
- my $useCB = Wx::CheckBox->new( $self, id('EnableFPSBind'), 'Enable FPS Binds');
+ my $useCB = Wx::CheckBox->new( $Tab, id('EnableFPSBind'), 'Enable FPS Binds');
$useCB->SetToolTip(Wx::ToolTip->new('Check this to enable the FPS and Netgraph Toggle Binds'));
$sizer->Add($useCB, 0, wxALL, 10);
my $minisizer = Wx::FlexGridSizer->new(0,2,5,5);
- $minisizer->Add( Wx::StaticText->new($self, -1, 'Toggle FPS/Netgraph'), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
- $minisizer->Add( Wx::Button-> new($self, id('FPSKeySelect'), $FPS->{'Bindkey'}));
+ $minisizer->Add( Wx::StaticText->new($Tab, -1, 'Toggle FPS/Netgraph'), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
+ $minisizer->Add( Wx::Button-> new($Tab, id('FPSKeySelect'), $FPS->{'Bindkey'}));
$sizer->Add($minisizer);
- $self->SetSizerAndFit($sizer);
+ $Tab->SetSizerAndFit($sizer);
return $self;
}
View
@@ -9,12 +9,12 @@ use Wx::Event qw( :everything );
use GameData;
use Utility qw(id);
-sub new {
- my ($class, $profile) = @_;
+sub InitKeys {
+ my $self = shift;
- my $self = $class->SUPER::new($profile);
+ $self->Profile->AddModule('General');
- $profile->{'General'} ||= {
+ $self->Profile->General ||= {
Archetype => 'Scrapper',
Origin => "Magic",
Primary => 'Martial Arts',
@@ -24,80 +24,87 @@ sub new {
ResetFile => BindFile->new('reset.txt'),
'Reset Key' => 'CTRL-M',
};
- my $general = $profile->{'General'};
+}
+
+sub FillTab {
+
+ my $self = shift;
+
+ $self->TabTitle = 'General';
+
+ my $General = $self->Profile->General;
+ my $Tab = $self->Tab;
my $topSizer = Wx::FlexGridSizer->new(0,2,5,5);
# Name
- $topSizer->Add( Wx::StaticText->new( $self, -1, "Name:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
- my $tc = Wx::TextCtrl->new( $self, id('PROFILE_NAMETEXT'), "",);
+ $topSizer->Add( Wx::StaticText->new( $Tab, -1, "Name:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
+ my $tc = Wx::TextCtrl->new( $Tab, id('PROFILE_NAMETEXT'), "",);
# TODO -- suss out what we want the min size to be, and set it someplace sane.
$tc->SetMinSize([300,-1]);
$topSizer->Add( $tc, 0, wxALL,) ;
# Archetype
- $topSizer->Add( Wx::StaticText->new( $self, -1, "Archetype:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
+ $topSizer->Add( Wx::StaticText->new( $Tab, -1, "Archetype:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
$topSizer->Add( Wx::BitmapComboBox->new(
- $self, id('PICKER_ARCHETYPE'), $general->{'Archetype'},
+ $Tab, id('PICKER_ARCHETYPE'), $General->{'Archetype'},
wxDefaultPosition, wxDefaultSize,
[sort keys %$GameData::Archetypes],
wxCB_READONLY,
), 0, wxALL,);
# Origin
- $topSizer->Add( Wx::StaticText->new( $self, -1, "Origin:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
+ $topSizer->Add( Wx::StaticText->new( $Tab, -1, "Origin:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
$topSizer->Add( Wx::BitmapComboBox->new(
- $self, id('PICKER_ORIGIN'), $general->{'Origin'},
+ $Tab, id('PICKER_ORIGIN'), $General->{'Origin'},
wxDefaultPosition, wxDefaultSize,
[@GameData::Origins],
wxCB_READONLY,
), 0, wxALL,);
# Primary
- $topSizer->Add( Wx::StaticText->new( $self, -1, "Primary Powerset:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
+ $topSizer->Add( Wx::StaticText->new( $Tab, -1, "Primary Powerset:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
$topSizer->Add( Wx::BitmapComboBox->new(
- $self, id('PICKER_PRIMARY'), $general->{'Primary'},
+ $Tab, id('PICKER_PRIMARY'), $General->{'Primary'},
wxDefaultPosition, wxDefaultSize,
- [sort keys %{$GameData::PowerSets->{$general->{'Archetype'}}->{'Primary'}}],
+ [sort keys %{$GameData::PowerSets->{$General->{'Archetype'}}->{'Primary'}}],
wxCB_READONLY,
), 0, wxALL,);
# Secondary
- $topSizer->Add( Wx::StaticText->new( $self, -1, "Secondary Powerset:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
+ $topSizer->Add( Wx::StaticText->new( $Tab, -1, "Secondary Powerset:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
$topSizer->Add( Wx::BitmapComboBox->new(
- $self, id('PICKER_SECONDARY'), $general->{'Secondary'},
+ $Tab, id('PICKER_SECONDARY'), $General->{'Secondary'},
wxDefaultPosition, wxDefaultSize,
- [sort keys %{$GameData::PowerSets->{$general->{'Archetype'}}->{'Secondary'}}],
+ [sort keys %{$GameData::PowerSets->{$General->{'Archetype'}}->{'Secondary'}}],
wxCB_READONLY,
), 0, wxALL,);
- $topSizer->Add( Wx::StaticText->new( $self, -1, "Binds Directory:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
+ $topSizer->Add( Wx::StaticText->new( $Tab, -1, "Binds Directory:"), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT,);
$topSizer->Add( Wx::DirPickerCtrl->new(
- $self, -1, $general->{'BindsDir'},
+ $Tab, -1, $General->{'BindsDir'},
'Select Binds Directory',
wxDefaultPosition, wxDefaultSize,
wxDIRP_USE_TEXTCTRL|wxALL,
), 0, wxALL|wxEXPAND,);
- $self->addLabeledButton($topSizer, $general, 'Reset Key', 'This key is used by certain modules to reset binds to a sane state.');
+ $self->addLabeledButton($topSizer, $General, 'Reset Key', 'This key is used by certain modules to reset binds to a sane state.');
- $topSizer->Add ( Wx::CheckBox->new($self, id('Enable Reset Feedback'), 'Enable Reset Feedback'), 0, wxALL);
+ $topSizer->Add ( Wx::CheckBox->new($Tab, id('Enable Reset Feedback'), 'Enable Reset Feedback'), 0, wxALL);
$topSizer->AddSpacer(5);
- $topSizer->Add( Wx::Button->new( $self, id('Write Binds Button'), 'Write Binds!' ), 0, wxALL|wxEXPAND);
-
- EVT_BUTTON( $self, id('Write Binds Button'), \&BindFile::WriteBindFiles );
+ $topSizer->Add( Wx::Button->new( $Tab, id('Write Binds Button'), 'Write Binds!' ), 0, wxALL|wxEXPAND);
+ EVT_BUTTON( $Tab, id('Write Binds Button'), \&BindFile::WriteBindFiles );
- $self->SetSizer($topSizer);
- EVT_COMBOBOX( $self, id('PICKER_ARCHETYPE'), \&pickArchetype );
- EVT_COMBOBOX( $self, id('PICKER_ORIGIN'), \&pickOrigin );
- EVT_COMBOBOX( $self, id('PICKER_PRIMARY'), \&pickPrimaryPowerSet );
- EVT_COMBOBOX( $self, id('PICKER_SECONDARY'), \&pickSecondaryPowerSet );
+ $Tab->SetSizer($topSizer);
- $self->{'TabTitle'} = 'General';
+ EVT_COMBOBOX( $Tab, id('PICKER_ARCHETYPE'), \&pickArchetype );
+ EVT_COMBOBOX( $Tab, id('PICKER_ORIGIN'), \&pickOrigin );
+ EVT_COMBOBOX( $Tab, id('PICKER_PRIMARY'), \&pickPrimaryPowerSet );
+ EVT_COMBOBOX( $Tab, id('PICKER_SECONDARY'), \&pickSecondaryPowerSet );
return $self;
@@ -9,15 +9,14 @@ use Wx qw( :everything );
use Utility qw(id);
-sub new {
+sub InitKeys {
- my ($class, $profile) = @_;
+ my $self = shift;
- my $self = $class->SUPER::new($profile);
- $self->{'TabTitle'} = 'Inspiration Popper';
+ $self->Profile->AddModule('InspPop');
- $profile->{'InspPop'} ||= {
+ $self->Profile->InspPop ||= {
Enable => undef,
AccuracyKey => "LSHIFT+A",
HealthKey => "LSHIFT+S",
@@ -27,7 +26,16 @@ sub new {
BreakFreeKey => "LSHIFT+E",
ResistDamageKey => "LSHIFT+SPACE",
};
- my $InspPop = $profile->{'InspPop'};
+}
+
+sub FillTab {
+
+ my $self = shift;
+
+ $self->TabTitle = 'Inspiration Popper';
+
+ my $InspPop = $self->Profile->InspPop;
+ my $Tab = $self->Tab;
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
@@ -47,59 +55,59 @@ sub new {
my $RowSet = $order ? $RevInspRows : $InspRows;
- $RowSet->Add ( Wx::StaticText->new($self, -1, "$order $Insp Key"), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
+ $RowSet->Add ( Wx::StaticText->new($Tab, -1, "$order $Insp Key"), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
- $KeyPicker = Wx::Button-> new($self, id("${order}${Insp}Key"), $InspPop->{"${order}${Insp}Key"});
+ $KeyPicker = Wx::Button-> new($Tab, id("${order}${Insp}Key"), $InspPop->{"${order}${Insp}Key"});
$KeyPicker->SetToolTip( Wx::ToolTip->new("Choose the key combo to activate a $Insp inspiration") );
$RowSet->Add ( $KeyPicker, 0, wxEXPAND);
$RowSet->AddStretchSpacer(wxEXPAND);
- $ColorsCB = Wx::CheckBox-> new($self, id("${order}${Insp}Colors"), '');
+ $ColorsCB = Wx::CheckBox-> new($Tab, id("${order}${Insp}Colors"), '');
$ColorsCB->SetToolTip( Wx::ToolTip->new("Colorize Inspiration-Popper chat feedback") );
$RowSet->Add ( $ColorsCB, 0, wxALIGN_CENTER_VERTICAL);
- $RowSet->Add( Wx::StaticText->new($self, -1, "Border"), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
+ $RowSet->Add( Wx::StaticText->new($Tab, -1, "Border"), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
$bc = $InspPop->{"${order}${Insp}Colors"}->{'border'};
$RowSet->Add( Wx::ColourPickerCtrl->new(
- $self, id("${order}${Insp}BorderColor"),
+ $Tab, id("${order}${Insp}BorderColor"),
Wx::Colour->new($bc->{'r'}, $bc->{'g'}, $bc->{'b'}),
wxDefaultPosition, wxDefaultSize,
)
);
- $RowSet->Add( Wx::StaticText->new($self, -1, "Background"), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
+ $RowSet->Add( Wx::StaticText->new($Tab, -1, "Background"), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
$bc = $InspPop->{"${order}${Insp}Colors"}->{'background'};
$RowSet->Add( Wx::ColourPickerCtrl->new(
- $self, id("${order}${Insp}BackgroundColor"),
+ $Tab, id("${order}${Insp}BackgroundColor"),
Wx::Colour->new($bc->{'r'}, $bc->{'g'}, $bc->{'b'}),
wxDefaultPosition, wxDefaultSize,
)
);
- $RowSet->Add( Wx::StaticText->new($self, -1, "Text"), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
+ $RowSet->Add( Wx::StaticText->new($Tab, -1, "Text"), 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
$fc = $InspPop->{"${order}${Insp}Colors"}->{'foreground'};
$RowSet->Add( Wx::ColourPickerCtrl->new(
- $self, id("${order}${Insp}ForegroundColor"),
+ $Tab, id("${order}${Insp}ForegroundColor"),
Wx::Colour->new($fc->{'r'}, $fc->{'g'}, $fc->{'b'}),
wxDefaultPosition, wxDefaultSize,
)
);
}
}
- my $useCB = Wx::CheckBox->new( $self, -1, 'Enable Inspiration Popper Binds (prefer largest)');
+ my $useCB = Wx::CheckBox->new( $Tab, -1, 'Enable Inspiration Popper Binds (prefer largest)');
$useCB->SetToolTip(Wx::ToolTip->new('Check this to enable the Inspiration Popper Binds, (largest used first)'));
$sizer->Add($useCB, 0, wxALL, 10);
$sizer->Add($InspRows);
- my $useRevCB = Wx::CheckBox->new( $self, -1, 'Enable Reverse Inspiration Popper Binds (prefer smallest)');
+ my $useRevCB = Wx::CheckBox->new( $Tab, -1, 'Enable Reverse Inspiration Popper Binds (prefer smallest)');
$useCB->SetToolTip(Wx::ToolTip->new('Check this to enable the Reverse Inspiration Popper Binds, (smallest used first)'));
$sizer->Add($useRevCB, 0, wxALL, 10);
$sizer->Add($RevInspRows);
- $self->SetSizerAndFit($sizer);
+ $Tab->SetSizerAndFit($sizer);
return $self;
}
Oops, something went wrong.

0 comments on commit 1a05bd4

Please sign in to comment.