summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-03-26 11:30:43 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-03-26 11:30:43 +0200
commita88765c209c60e039c95507c2c9db73273b93fde (patch)
treeb804505be04c8c53b17dcdd136cbdeaa10a53d52
parent3c0333dab7b478831182dbf61da7c80dda1c358f (diff)
Stops having tiles behave as an table.
Maybe this will improve performances.
-rw-r--r--src/battlemap/src/View/Battlemap.elm96
-rw-r--r--src/battlemap/src/View/Battlemap/Tile.elm27
-rw-r--r--src/battlemap/www/style.css20
3 files changed, 61 insertions, 82 deletions
diff --git a/src/battlemap/src/View/Battlemap.elm b/src/battlemap/src/View/Battlemap.elm
index e5e9d36..d9a98d1 100644
--- a/src/battlemap/src/View/Battlemap.elm
+++ b/src/battlemap/src/View/Battlemap.elm
@@ -12,6 +12,8 @@ import Html.Lazy
import List
-- Battlemap -------------------------------------------------------------------
+import Constants.UI
+
import Struct.Battlemap
import Struct.CharacterTurn
import Struct.Event
@@ -29,71 +31,45 @@ import View.Battlemap.Tile
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_tiles_line_html : (
- (List (Html.Html Struct.Event.Type)) ->
- (Html.Html Struct.Event.Type)
- )
-get_tiles_line_html tiles_list =
+get_tiles_html : Struct.Battlemap.Type -> (Html.Html Struct.Event.Type)
+get_tiles_html battlemap =
(Html.div
[
- (Html.Attributes.class "battlemap-tiles-layer-row")
+ (Html.Attributes.class "battlemap-tiles-layer"),
+ (Html.Attributes.style
+ [
+ (
+ "width",
+ (
+ (toString
+ (
+ (Struct.Battlemap.get_width battlemap)
+ * Constants.UI.tile_size
+ )
+ )
+ ++ "px"
+ )
+ ),
+ (
+ "height",
+ (
+ (toString
+ (
+ (Struct.Battlemap.get_height battlemap)
+ * Constants.UI.tile_size
+ )
+ )
+ ++ "px"
+ )
+ )
+ ]
+ )
]
- tiles_list
- )
-
-get_tiles_lines_html : (
- Int ->
- Struct.Tile.Type ->
- (
- Int,
- (List (Html.Html Struct.Event.Type)),
- (List (Html.Html Struct.Event.Type))
- ) ->
- (
- Int,
- (List (Html.Html Struct.Event.Type)),
- (List (Html.Html Struct.Event.Type))
+ (List.map
+ (View.Battlemap.Tile.get_html)
+ (Array.toList (Struct.Battlemap.get_tiles battlemap))
)
)
-get_tiles_lines_html max_index tile (curr_index, curr_line, result) =
- if (curr_index == 0)
- then
- (
- max_index,
- [],
- (
- (get_tiles_line_html
- ((View.Battlemap.Tile.get_html tile) :: curr_line)
- )
- ::
- result
- )
- )
- else
- (
- (curr_index - 1),
- ((View.Battlemap.Tile.get_html tile) :: curr_line),
- result
- )
-
-get_tiles_html : Struct.Battlemap.Type -> (Html.Html Struct.Event.Type)
-get_tiles_html battlemap =
- let
- bmap_width = (Struct.Battlemap.get_width battlemap)
- max_index = (bmap_width - 1)
- (_, last_line, other_lines) =
- (Array.foldr
- (get_tiles_lines_html max_index)
- (max_index, [], [])
- (Struct.Battlemap.get_tiles battlemap)
- )
- in
- (Html.div
- [
- (Html.Attributes.class "battlemap-tiles-layer")
- ]
- ((get_tiles_line_html last_line) :: other_lines)
- )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
diff --git a/src/battlemap/src/View/Battlemap/Tile.elm b/src/battlemap/src/View/Battlemap/Tile.elm
index 01761c5..1c3628c 100644
--- a/src/battlemap/src/View/Battlemap/Tile.elm
+++ b/src/battlemap/src/View/Battlemap/Tile.elm
@@ -6,6 +6,8 @@ import Html.Attributes
import Html.Events
-- Battlemap -------------------------------------------------------------------
+import Constants.UI
+
import Struct.Event
import Struct.Location
import Struct.Tile
@@ -35,20 +37,19 @@ get_html tile =
(Html.Attributes.class "clickable"),
(Html.Events.onClick
(Struct.Event.TileSelected (Struct.Location.get_ref tile_loc))
+ ),
+ (Html.Attributes.style
+ [
+ (
+ "top",
+ ((toString (tile_loc.y * Constants.UI.tile_size)) ++ "px")
+ ),
+ (
+ "left",
+ ((toString (tile_loc.x * Constants.UI.tile_size)) ++ "px")
+ )
+ ]
)
--- ),
--- (Html.Attributes.style
--- [
--- (
--- "top",
--- ((toString (tile_loc.y * Constants.UI.tile_size)) ++ "px")
--- ),
--- (
--- "left",
--- ((toString (tile_loc.x * Constants.UI.tile_size)) ++ "px")
--- )
--- ]
--- )
]
[
]
diff --git a/src/battlemap/www/style.css b/src/battlemap/www/style.css
index c9aa644..08f1e22 100644
--- a/src/battlemap/www/style.css
+++ b/src/battlemap/www/style.css
@@ -189,11 +189,11 @@
height: 32px;
width: 32px;
/** Fixes odd behavior of table cell being resized. **/
- min-width: 32px;
- max-width: 32px;
+ /* min-width: 32px; */
+ /* max-width: 32px; */
}
-.battlemap-tile-icon {z-index: 0; display: table-cell;}
+.battlemap-tile-icon {z-index: 0; position: absolute;}
.battlemap-marker-icon {z-index: 1;}
.battlemap-character-icon {z-index: 2;}
.battlemap-path-icon {z-index: 3; color: white;}
@@ -206,12 +206,12 @@
}
.battlemap-tiles-layer
{
- display: table;
+ /*display: table; */
}
.battlemap-tiles-layer-row
{
- display: table-row;
+ /* display: table-row; */
}
.battlemap-character-icon
@@ -224,8 +224,9 @@
.battlemap-marker-icon
{
box-sizing: border-box;
- min-width: 24px;
- max-width: 24px;
+ width: 24px;
+ /*min-width: 24px;
+ max-width: 24px; */
margin: 4px 0 0 4px;
height: 24px;
border-radius: 4px;
@@ -252,8 +253,9 @@
.battlemap-can-attack-marker
{
background-color:rgba(0,0,0,0.7);
- min-width: 28px;
- max-width: 28px;
+ width: 28px;
+ /*min-width: 28px;
+ max-width: 28px;*/
height: 28px;
margin: 2px 0 0 2px;
border-radius: 0;