diff --git a/lib/aethyr/core/components/storage.rb b/lib/aethyr/core/components/storage.rb index d7dc82b65c5a4ef5dd026e35fc52fa6e6bf2c677..50c28333a9d17fc145c104545a1da219214e6a7b 100644 --- a/lib/aethyr/core/components/storage.rb +++ b/lib/aethyr/core/components/storage.rb @@ -66,6 +66,7 @@ class StorageMachine #Yeah, so whatever on this little deal. Probably should do it better later. player.use_color = player.io.display.use_color if player.io player.color_settings = player.io.display.color_settings if player.io + player.layout = player.io.display.layout_type if player.io #Okay, this is tricky. We can't serialize the IO object stored in the Player #objects. To get around this (we don't want to store it anyhow), we temporarily diff --git a/lib/aethyr/core/connection/login.rb b/lib/aethyr/core/connection/login.rb index 8db2ca23938864114f4cfe958682d1cd166d6a47..8f7059aa5fb66be577398855d82400f1141224b6 100644 --- a/lib/aethyr/core/connection/login.rb +++ b/lib/aethyr/core/connection/login.rb @@ -160,7 +160,8 @@ module Login end - @display.color_settings = player.color_settings if not player.color_settings.nil? + @display.color_settings = player.color_settings unless player.color_settings.nil? + @display.layout(layout: player.layout, in_combat: player.info.in_combat) unless player.layout.nil? @word_wrap = player.word_wrap player.instance_variable_set(:@player, self) diff --git a/lib/aethyr/core/objects/player.rb b/lib/aethyr/core/objects/player.rb index 3c5aa377837e05437c4977d7203107634afe0205..b36f9719df2db4620056c648e7491917e71051dc 100644 --- a/lib/aethyr/core/objects/player.rb +++ b/lib/aethyr/core/objects/player.rb @@ -41,7 +41,7 @@ class Player < LivingObject } attr_reader :admin, :color_settings - attr_accessor :use_color, :reply_to, :page_height + attr_accessor :use_color, :reply_to, :page_height, :layout #Create a new player object with the given socket connection. You must also pass in a game_object_id and a room, although if you pass in nil for game_object_id it will auto-generate one for you. def initialize(connection, game_object_id, room, *args) @@ -58,6 +58,9 @@ class Player < LivingObject @blind = false @reply_to = nil @prompt_shown = false + @layout = :basic + @player.display.layout(layout: @layout, in_combat: info.in_combat) + info.stats.satiety = 120 map_skill = Aethyr::Extensions::Skills::Map.new(self.game_object_id) kick_skill = Aethyr::Extensions::Skills::Kick.new(self.game_object_id) diff --git a/lib/aethyr/core/render/display.rb b/lib/aethyr/core/render/display.rb index 407a6d86dbf6f1775db1935a70f76b1cc08c5fa0..127cdb664002b67c7e7f7a8b5c63cd378a6fd807 100644 --- a/lib/aethyr/core/render/display.rb +++ b/lib/aethyr/core/render/display.rb @@ -6,6 +6,7 @@ require 'aethyr/core/components/manager' require 'aethyr/core/render/window' class Display + attr_reader :layout_type attr_accessor :color_settings, :use_color DEFAULT_HEIGHT = 43 @@ -79,15 +80,30 @@ class Display end end - def layout(in_fight: false) + def layout(layout: @layout_type, in_combat: false) + @layout_type = layout if @layout_type == :full && @height > 100 && @width > 165 - unless in_fight + unless in_combat + @windows[:fight_enemy].destroy + @windows[:fight_team].destroy + @windows[:fight_queue].destroy @windows[:map].create(height: @height/2) @windows[:look].create(height: @height/2 - 3, width: 83, y: @height/2) @windows[:main].create(height: @height/2 - 3, x: 83, y: @height/2) @windows[:input].create(height: 3, y: @height - 3) + else + @windows[:map].destroy + @windows[:look].destroy + @windows[:fight_enemy].create(height: @height/3 - 1, width: @width - 83) + @windows[:fight_team].create(height: @height/3 - 1, width: @width - 83, y: @height/3) + @windows[:fight_queue].create(height: @height - 3, width: 83, x: @width - 83) + @windows[:main].create(height: @height/3 - 1, width: @width - 83, y: @height/2) + @windows[:input].create(height: 3, y: @height - 3) end else + @windows[:fight_enemy].destroy + @windows[:fight_team].destroy + @windows[:fight_queue].destroy @windows[:map].destroy @windows[:look].destroy @windows[:main].create(height: @height - 2) @@ -106,7 +122,6 @@ class Display @width = resolution[0] @height = resolution[1] Ncurses.resizeterm(@height, @width) - @layout_type = :full layout end