| 1 | package Games::Rezrov::ZIO_Color; | ||
| 2 | # | ||
| 3 | # stuff for ZIOs that have color support | ||
| 4 | # | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use Games::Rezrov::MethodMaker qw( | ||
| 8 | |||
| 9 | cc | ||
| 10 | fg | ||
| 11 | bg | ||
| 12 | default_fg | ||
| 13 | default_bg | ||
| 14 | sfg | ||
| 15 | sbg | ||
| 16 | |||
| 17 | ); | ||
| 18 | |||
| 19 | use constant DEFAULT_BACKGROUND_COLOR => 'blue'; | ||
| 20 | use constant DEFAULT_FOREGROUND_COLOR => 'white'; | ||
| 21 | use constant DEFAULT_CURSOR_COLOR => 'black'; | ||
| 22 | |||
| 23 | sub parse_color_options { | ||
| 24 | # - interpret standard command-line options for colors | ||
| 25 | # - set up defaults | ||
| 26 | my ($self, $options) = @_; | ||
| 27 | my $fg = lc($options->{"fg"} || DEFAULT_FOREGROUND_COLOR); | ||
| 28 | my $bg = lc($options->{"bg"} || DEFAULT_BACKGROUND_COLOR); | ||
| 29 | my $sfg = lc($options->{"sfg"} || $bg); | ||
| 30 | my $sbg = lc($options->{"sbg"} || $fg); | ||
| 31 | # status line: default to inverse of foreground/background colors | ||
| 32 | |||
| 33 | $self->fg($fg); | ||
| 34 | $self->bg($bg); | ||
| 35 | $self->default_fg($fg); | ||
| 36 | $self->default_bg($bg); | ||
| 37 | $self->sfg($sfg); | ||
| 38 | $self->sbg($sbg); | ||
| 39 | |||
| 40 | my $cc = lc($options->{"cc"} || DEFAULT_CURSOR_COLOR); | ||
| 41 | $self->cc($cc eq $bg ? $fg : $cc); | ||
| 42 | # if cursor color is the same as the background color, | ||
| 43 | # change it to the foreground color | ||
| 44 | } | ||
| 45 | |||
| 46 | 1; |