Deliantra-Client

 view release on metacpan or  search on metacpan

DC/Item.pm  view on Meta::CPAN

      },
      on_escape => sub { $w->destroy; 1 },
   );
   $entry->grab_focus;
   $w->show;
}

my $bg_cursed = [1  , 0  , 0, 0.5];
my $bg_magic  = [0.2, 0.2, 1, 0.5];

sub update_widgets {
   my ($self) = @_;

   # necessary to avoid cyclic references
   DC::weaken $self;

   my $button_cb = sub {
      my (undef, $ev, $x, $y) = @_;

      my $targ = $::CONN->{player}{tag};

DC/MapWidget.pm  view on Meta::CPAN


sub size_request {
   my ($self) = @_;

   (
      $self->{tilesize} * DC::ceil $::WIDTH  / $self->{tilesize},
      $self->{tilesize} * DC::ceil $::HEIGHT / $self->{tilesize},
   )
}

sub update {
   my ($self) = @_;

   $self->{need_update} = 1;
   $self->SUPER::update;
}

my %DIR = (
   ( "," . DC::SDLK_KP5      ), [0, "stay fire"],
   ( "," . DC::SDLK_KP8      ), [1, "north"],
   ( "," . DC::SDLK_KP9      ), [2, "northeast"],

DC/MapWidget.pm  view on Meta::CPAN

}

sub invoke_size_allocate {
   my ($self, $w, $h) = @_;

   $self->update;

   1
}

sub update {
   my ($self) = @_;

   delete $self->{texture_atime};
   $self->SUPER::update;
}

sub _draw {
   my ($self) = @_;

   $self->{root}->on_post_alloc (texture => sub { $self->refresh_hook });

DC/MapWidget.pm  view on Meta::CPAN

   $self->{entry}->set_text ("");
}

sub inject_key_down {
   my ($self, $ev) = @_;

   $self->{entry}->grab_focus;
   $self->{entry}->emit (key_down => $ev);
}

sub update_labels {
   my ($self) = @_;

   my $text = $self->{entry}->get_text;

   length $text
      or return $self->hide;

   if ($text ne $self->{last_search}) {
      my @match;

DC/MessageDistributor.pm  view on Meta::CPAN

sub touch_channel {
   my ($self, $id) = @_;

   if (exists $self->{chatview}->{$id}) {
      $self->update_chat ($id);
   } else {
      $self->init_chat ($id);
   }
}

sub update_chat {
   my ($self, $id) = @_;

   $self->{chatview}->{$id}->update_info ($self->{info}->{$id});
}

sub init_chat {
   my ($self, $id) = @_;

   my $chaninfo = $self->{info}->{$id};
   my $dock = $self->{chatview}->{$id} =

DC/Protocol.pm  view on Meta::CPAN

#   };

   $self->{open_container} = 0;

   # per server
   $self->{mapcache} = "mapcache_$self->{host}_$self->{port}";

   $self
}

sub update_fx_want {
   my ($self) = @_;

   $self->send_exti_msg (fx_want => {
      3 => !!$::CFG->{bgm_enable},   # FT_MUSIC
      5 => !!$::CFG->{audio_enable}, # FT_SOUND
      6 => 1,                        # FT_RSRC
   });
}

sub ext_capabilities {

DC/Protocol.pm  view on Meta::CPAN

   slow  => CS_STAT_RES_SLOW,
   para  => CS_STAT_RES_PARA,
   tund  => CS_STAT_TURN_UNDEAD,
   fear  => CS_STAT_RES_FEAR,
   depl  => CS_STAT_RES_DEPLETE,
   deat  => CS_STAT_RES_DEATH,
   holyw => CS_STAT_RES_HOLYWORD,
   blind => CS_STAT_RES_BLIND,
);

sub update_stats_window {
   my ($self, $stats, $prev) = @_;

   # I love text protocols...

   my $hp   = $stats->{+CS_STAT_HP} * 1;
   my $hp_m = $stats->{+CS_STAT_MAXHP} * 1;
   my $sp   = $stats->{+CS_STAT_SP} * 1;
   my $sp_m = $stats->{+CS_STAT_MAXSP} * 1;
   my $fo   = $stats->{+CS_STAT_FOOD} * 1;
   my $fo_m = 999;

DC/Protocol.pm  view on Meta::CPAN

}

sub eof {
   my ($self) = @_;

   $self->{map_widget}->clr_commands;

   ::stop_game ();
}

sub update_floorbox {
   $DC::UI::ROOT->on_refresh ($::FLOORBOX => sub {
      return unless $::CONN;

      $::FLOORBOX->clear;

      my @add;

      my $row;
      for (sort { $b->{count} <=> $a->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) {
         next if $_->{tag} & 0x80000000;

DC/Protocol.pm  view on Meta::CPAN

            $::CONN->send ("apply $tag") # $::CONN->{open_container}")
               if $tag != 0;
            0
         },
      );
   }

   $::INVR->set_items ($conn->{container}{$tag});
}

sub update_containers {
   my ($self) = @_;

   $DC::UI::ROOT->on_refresh ("update_containers_$self" => sub {
      my $todo = delete $self->{update_container}
         or return;

      for my $tag (keys %$todo) {
         update_floorbox if $tag == 0 or $tag == $self->{open_container};
         if ($tag == 0) {
            $::INVR->set_items ($self->{container}{0})

DC/Protocol.pm  view on Meta::CPAN

      $self->update_containers;
   }
}

sub player_update {
   my ($self, $player) = @_;

   $self->update_weight;
}

sub update_weight {
   my ($self) = @_;

   my $weight = .001 * $self->{player}{weight};
   my $limit  = .001 * $self->{stat}{+CS_STAT_WEIGHT_LIM};

   $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $weight);
   $::STATWIDS->{m_weight}->set_text (sprintf "Max Weight: %.1fkg", $limit);
   $::STATWIDS->{i_weight}->set_text (sprintf "%.1f/%.1fkg", $weight, $limit);
}

sub update_server_info {
   my ($self) = @_;

   my @yesno = ("<span foreground='red'>no</span>", "<span foreground='green'>yes</span>");

   my $version = JSON::XS->new->encode ($self->{s_version});

   $::SERVER_INFO->set_markup (
      "server <tt>$self->{host}:$self->{port}</tt>\n"
    . "protocol version <tt>$version</tt>\n"
    . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"

DC/Protocol.pm  view on Meta::CPAN


   $self->{textview}->add_paragraph ({
      fg     => [1, 1, 0, 1],
      markup => "<small>[starting conversation with <b>$self->{title}</b>]</small>\n\n",
   });

   $self->show;
   $self
};

sub update_options {
   my ($self) = @_;

   DC::weaken $self;

   $self->{options}->clear;
   $self->{options}->add ($self->{bye_button});

   for my $kw (sort keys %{ $self->{kw} }) {
      $self->{options}->add (new DC::UI::Button
         text => $kw,

DC/UI.pm  view on Meta::CPAN

      return if $self->{root}{realloc}{$self+0};

      $self->{root}{realloc}{$self+0} = $self;
      $self->{root}->update;
   } else {
      delete $self->{req_w};
      delete $self->{req_h};
   }
}

sub update {
   my ($self) = @_;

   $self->{parent}->update
      if $self->{parent};
}

sub reconfigure {
   my ($self) = @_;

   $self->realloc;

DC/UI.pm  view on Meta::CPAN

our @ISA = DC::UI::Bin::;

use DC::OpenGL;

sub new {
   my ($class, %arg) = @_;

   my $self = $class->SUPER::new (%arg);
}

sub update {
   my ($self) = @_;

   $ROOT->on_post_alloc ($self => sub { $self->render_child });
   $self->SUPER::update;
}

sub invoke_size_allocate {
   my ($self, $w, $h) = @_;

   $self->update;

DC/UI.pm  view on Meta::CPAN

sub add {
   my ($self, $widget) = @_;

   $self->{vp}->add ($self->{child} = $widget);
}

sub set_offset   { shift->{vp}->set_offset   (@_) }
sub set_center   { shift->{vp}->set_center   (@_) }
sub make_visible { shift->{vp}->make_visible (@_) }

sub update_slider {
   my ($self) = @_;

   my $child = ($self->{vp} or return)->child;

   if ($self->{scroll_x}) {
      my ($w1, $w2) = ($child->{req_w}, $self->{vp}{w});
      $self->{hslider}->set_range ([$self->{hslider}{range}[0], 0, $w1, $w2, 1]);

      my $visible = $w1 > $w2;
      if ($visible != $self->{hslider_visible}) {

DC/UI.pm  view on Meta::CPAN


   if (exists $self->{markup}) {
      $self->set_markup (delete $self->{markup});
   } else {
      $self->set_text (delete $self->{text});
   }

   $self
}

sub update {
   my ($self) = @_;

   delete $self->{texture};
   $self->SUPER::update;
}

sub realloc {
   my ($self) = @_;

   delete $self->{ox};

DC/UI.pm  view on Meta::CPAN


   my $delta = $self->{vertical} ? $ev->{dy} : $ev->{dx};

   my $pagepart = $ev->{mod} & DC::KMOD_SHIFT ? 1 : 0.2;

   $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart);

   1
}

sub update {
   my ($self) = @_;

   delete $self->{knob_w};
   $self->SUPER::update;
}

sub _draw {
   my ($self) = @_;

   unless ($self->{knob_w}) {

DC/UI.pm  view on Meta::CPAN

      $self->{children}[1]->set_range ([$self->{children}[1]{range}[0], 0, $height, $H, 1]);

      delete $self->{texture};
   }

   if (my $paridx = delete $self->{scroll_to}) {
      $self->{children}[1]->set_value ($self->{par}[$paridx]{y});
   }
}

sub update {
   my ($self) = @_;

   $self->SUPER::update;

   return unless $self->{h} > 0;

   delete $self->{texture};

   $ROOT->on_post_alloc ($self => sub {
      $self->force_uptodate;

DC/UI.pm  view on Meta::CPAN

      aspect     => 1,
      can_events => 0,
      @_,
   );

   $self->update_anim;
   
   $self
}

sub update_timer {
   my ($self) = @_;

   return unless $self->{timer};

   if ($self->{visible}) {
      $self->{timer}->start;
   } else {
      $self->{timer}->stop;
   }
}

sub update_face {
   my ($self) = @_;

   if ($::CONN) {
      if (my $anim = $::CONN->{anim}[$self->{anim}]) {
         if ($anim && @$anim) {
            $self->{face} = $anim->[ $self->{frame} % @$anim ];
            delete $self->{face_change_cb};

            if (my $tex = $self->{tex} = $::CONN->{texture}[ $::CONN->{face}[$self->{face}]{id} ]) {
               unless ($tex->{name} || $tex->{loading}) {
                  $tex->upload (sub { $self->reconfigure });
               }
            }
         }
      }
   }
}

sub update_anim {
   my ($self) = @_;

   if ($self->{anim} && $self->{animspeed}) {
      DC::weaken (my $widget = $self);

      $self->{animspeed} = List::Util::max 0.05, $self->{animspeed};
      $self->{timer} = EV::periodic_ns 0, $self->{animspeed}, undef, sub {
         return unless $::CONN;

         my $w = $widget

DC/UI.pm  view on Meta::CPAN

            }
         }

         $self->{face_change_cb} ||= $::CONN->on_face_change ($self->{face}, sub { $self->reconfigure });
      }
   }

   ($self->{size_w} || 8, $self->{size_h} || 8)
}

sub update {
   my ($self) = @_;

   return unless $self->{visible};

   $self->SUPER::update;
}

sub set_face {
   my ($self, $face) = @_;

DC/UI.pm  view on Meta::CPAN


   ($x, $y)
}

sub coord2global {
   my ($self, $x, $y) = @_;

   ($x, $y)
}

sub update {
   my ($self) = @_;

   $::WANT_REFRESH = 1;
}

sub add {
   my ($self, @children) = @_;

   $_->{is_toplevel} = 1
      for @children;

DC/UI/ChatView.pm  view on Meta::CPAN

      },
   ));

   $self->{initiated} = 1; # for update_info
   $self->update_tooltip;

   $self
}

# (private) This method updates the channel info associated with this chat view.
sub update_info {
   my ($self, $info) = @_;
   $self->{title}         = $info->{title};
   $self->{text_tooltip}  = $info->{tooltip};
   $self->{say_command}   = $info->{reply};
   $self->{entry_tooltip} =
      $info->{entry_tooltip}
      || "Enter a message and press enter to send it to the channel '$info->{title}'.";

   if ($self->{initiated}) {
      $self->{say_command_label}->set_markup ($self->{say_command});
      $self->set_title ($self->{title});
      $self->update_tooltip;
   }
}

# updates only the 
sub update_tooltip {
   my ($self) = @_;
   my $t = $self->{text_tooltip}
           . (defined $self->{dockbar_pos}
                 ? "\n\n<small>Alt+"
                   . ($self->{dockbar_pos} == 9 ? '0' : $self->{dockbar_pos} + 1)
                   . " - activates this tab.\n"
                   . "Return - toggles activity of the entry."
                   . "</small>"
                 : "");
   $self->{c_tab}->set_tooltip ($t);

DC/UI/Dockable.pm  view on Meta::CPAN

# (private) This method tells the dockable that it is 'active', which means:
# it is docked and it's tab has been activated and it is currently shown.
sub set_dockbar_tab_active {
   my ($self, $active) = @_;
   $self->{dockbar_active} = $active;
   $self->update_tab;
}

# (private) This method updates the tab and other things of the dockable
# whenever something has been changed (title, color, ...)
sub update_tab {
   my ($self) = @_;
   # TODO: set color according to dockbar_active

   my $oldcolor = $self->{tab_label}->{fg};
   if ($self->is_docked_active) {
      $self->{tab_label}->{fg} = $self->{active_fg}   || [1, 1, 1];
   } else {
      $self->{tab_label}->{fg} = $self->{inactive_fg} || [1, 1, 1,];
   }
   if (join (',', @$oldcolor) ne join (',', @{$self->{tab_label}->{fg}})) {

DC/UI/Dockbar.pm  view on Meta::CPAN


   # here the assumption is done that $dockable is inserted at the end of the
   # notebook tabs, so that the other tabs dont have to be updated
   $self->{notebook}->add ($dockable);
   $dockable->set_dockbar_pos ($self->{notebook}->page_index ($dockable));
   $self->update_active;
}

# (private) This method updates all docked tabs and tells them whether their
# tab is 'active'.
sub update_active {
   my ($self, $page) = @_;

   unless ($page) {
      $page = $self->{notebook}->get_current_page;
   }

   for ($self->{notebook}->pages) {
      $_->set_dockbar_tab_active ($_ eq $page);
   }
}

DC/UI/Dockbar.pm  view on Meta::CPAN

   $self->{notebook}->remove ($dockable);
   my $nextpage = ($self->{notebook}->pages)[0];
   $self->{notebook}->set_current_page ($nextpage)
      if $nextpage;
   $dockable->set_dockbar_pos (undef);
   $dockable->set_dockbar_tab_active (undef);
   $self->update_dockbar_positions;
}

# (private) This method updates the position of the dockables in the dockbar.
sub update_dockbar_positions {
   my ($self) = @_;
   my $i = 0;
   for ($self->{notebook}->pages) {
      $_->set_dockbar_pos ($i++);
   }
}

# Returns all Dockables of this Dockbar
sub dockables {
   my ($self) = @_;

DC/UI/Inventory.pm  view on Meta::CPAN

      col_expand => [0, 1, 0],
      items      => [],
      @_,
   );

   $self->set_sort_order (undef);

   $self
}

sub update_items {
   my ($self) = @_;

   $self->clear;

   my @item = $self->{sort}->(@{ $self->{items} });

   my @adds;
   my $row = 0;
   for my $item ($self->{sort}->(@{ $self->{items} })) {
      DC::Item::update_widgets $item;

bin/deliantra  view on Meta::CPAN

}

sub debug {
   $DEBUG_STATUS->set_text ($_[0]);
}

sub message {
   $MESSAGE_DIST->message (@_);
}

sub update_modbox {
   my $mod = DC::SDL_GetModState;

   my $markup;

   $markup .= $mod & DC::KMOD_CTRL
              ? ($MAPWIDGET->{ctrl} ? "[REPEAT]" : "[<span foreground='#888'>REPEAT</span>]")
              : "[<span foreground='#888'> once </span>]";

   $markup .= $mod & DC::KMOD_SHIFT
              ? ($MAPWIDGET->{shft} ? "[FIRE]" : "[<span foreground='#888'>FIRE</span>]")

bin/deliantra  view on Meta::CPAN


   $sw
}

sub formsep($) {
   scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1
}

my $METASERVER_ATIME;

sub update_metaserver {
   my ($metaserver_dialog) = @_;

   $METASERVER = $metaserver_dialog
      if defined $metaserver_dialog;

   return if $METASERVER_ATIME > time;
   $METASERVER_ATIME = time + 60;

   my $table = $METASERVER->{table};
   $table->clear;



( run in 0.678 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )