Skip to content

Commit

Permalink
#255 Fixed various smaller issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Wotuu committed Mar 9, 2020
1 parent 5b422e3 commit 6eecd30
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 29 deletions.
8 changes: 8 additions & 0 deletions app/Models/MapIcon.php
Expand Up @@ -24,6 +24,14 @@ class MapIcon extends Model

protected $visible = ['id', 'floor_id', 'map_icon_type_id', 'lat', 'lng', 'comment'];

protected $appends = ['has_dungeon_route'];


public function getEditableAttribute()
{
return $this->dungeon_route_id > 0;
}

/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
Expand Down
2 changes: 1 addition & 1 deletion database/seeds/ExpansionsSeeder.php
Expand Up @@ -27,7 +27,7 @@ public function run()
];


foreach($expansions as $name => $expansion){
foreach ($expansions as $name => $expansion) {
$expansion->name = $name;
// Temp file
$expansion->icon_file_id = -1;
Expand Down
42 changes: 24 additions & 18 deletions database/seeds/MapIconTypesSeeder.php
Expand Up @@ -17,30 +17,36 @@ public function run()

$mapIconData = [
'awakened_obelisk' => ['name' => 'Awakened Obelisk', 'admin_only' => true],
'comment' => ['name' => 'Comment'],
'door' => ['name' => 'Door', 'admin_only' => true],
'door_down' => ['name' => 'Door Down', 'admin_only' => true],
'door_left' => ['name' => 'Door Left', 'admin_only' => true],
'door_locked' => ['name' => 'Door Locked', 'admin_only' => true],
'door_right' => ['name' => 'Door Right', 'admin_only' => true],
'door_up' => ['name' => 'Door Up', 'admin_only' => true],
'dot_yellow' => ['name' => 'Yellow Dot'],
'dungeon_start' => ['name' => 'Dungeon Start', 'admin_only' => true],
'gateway' => ['name' => 'Gateway'],
'graveyard' => ['name' => 'Graveyard', 'admin_only' => true],
'greasebot' => ['name' => 'Grease bot (haste)', 'admin_only' => true],
'shockbot' => ['name' => 'Shock bot (damage)', 'admin_only' => true],
'warlock_gateway' => ['name' => 'Warlock Gateway'],
'weldingbot' => ['name' => 'Welding bot (-damage taken/+healing received)', 'admin_only' => true],
'comment' => ['name' => 'Comment'],
'door' => ['name' => 'Door', 'admin_only' => true],
'door_down' => ['name' => 'Door Down', 'admin_only' => true],
'door_left' => ['name' => 'Door Left', 'admin_only' => true],
'door_locked' => ['name' => 'Door Locked', 'admin_only' => true],
'door_right' => ['name' => 'Door Right', 'admin_only' => true],
'door_up' => ['name' => 'Door Up', 'admin_only' => true],
'dot_yellow' => ['name' => 'Yellow Dot'],
'dungeon_start' => ['name' => 'Dungeon Start', 'admin_only' => true],
'gateway' => ['name' => 'Gateway'],
'graveyard' => ['name' => 'Graveyard', 'admin_only' => true],
'greasebot' => ['name' => 'Grease bot (haste)', 'admin_only' => true],
'shockbot' => ['name' => 'Shock bot (damage)', 'admin_only' => true],
'warlock_gateway' => ['name' => 'Warlock Gateway'],
'weldingbot' => ['name' => 'Welding bot (-damage taken/+healing received)', 'admin_only' => true],
];

foreach ($mapIconData as $key => $mapIcon)
{
foreach ($mapIconData as $key => $mapIcon) {
$mapIconType = new MapIconType();
$mapIconType->key = $key;
$mapIconType->name = $mapIcon['name'];

$imageSize = getimagesize(resource_path(sprintf('/assets/images/mapicon/%s.png', $key)));
// Just in case it doesn't exist
$filePath = resource_path(sprintf('assets/images/mapicon/%s.png', $key));
if (file_exists($filePath)) {
$this->command->warn(sprintf('Unable to find file %s', $filePath));
$imageSize = getimagesize($filePath);
} else {
$imageSize = [16, 16];
}
$mapIconType->width = $imageSize[0];
$mapIconType->height = $imageSize[1];
$mapIconType->admin_only = isset($mapIcon['admin_only']) ? $mapIcon['admin_only'] : 0;
Expand Down
3 changes: 2 additions & 1 deletion resources/assets/css/map.css
Expand Up @@ -690,8 +690,9 @@ html, body, #map, #app, .wrapper {
}

.map_map_icon_comment_tooltip {
width: 240px;
max-width: 240px;
white-space: normal;
display: inline-block;
}

#map_ad_horizontal,
Expand Down
17 changes: 8 additions & 9 deletions resources/assets/js/custom/mapicon.js
Expand Up @@ -69,6 +69,7 @@ class MapIcon extends MapObject {
this.id = 0;
this.map_icon_type_id = 0;
this.map_icon_type = null;
this.has_dungeon_route = false;
this.comment = '';
this.label = 'MapIcon';

Expand Down Expand Up @@ -116,8 +117,8 @@ class MapIcon extends MapObject {
// Admin may edit everything, but not useful when editing a dungeonroute
console.warn(this.map_icon_type);
return this.map_icon_type !== null && (
(this.map_icon_type.admin_only && isUserAdmin && this.map.getDungeonRoute().publicKey === '') ||
(!this.map_icon_type.admin_only && this.map.getDungeonRoute().publicKey !== '')
((this.map_icon_type.admin_only && isUserAdmin && this.map.getDungeonRoute().publicKey === '') ||
!this.map_icon_type.admin_only)
);
}

Expand All @@ -126,13 +127,11 @@ class MapIcon extends MapObject {

this.unbindTooltip();

if (this.comment.length > 0) {
this.layer.bindTooltip(
jQuery('<div/>', {
class: 'map_map_icon_comment_tooltip'
}).text(this.comment)[0].outerHTML
);
}
this.layer.bindTooltip(
jQuery('<div/>', {
class: 'map_map_icon_comment_tooltip'
}).text(this.comment.length > 0 ? this.comment : this.map_icon_type.name)[0].outerHTML
);
}

edit() {
Expand Down
Expand Up @@ -69,6 +69,7 @@ class MapIconMapObjectGroup extends MapObjectGroup {
mapIcon.id = remoteMapObject.id;
mapIcon.floor_id = remoteMapObject.floor_id;
mapIcon.map_icon_type_id = remoteMapObject.map_icon_type_id;
mapIcon.has_dungeon_route = remoteMapObject.has_dungeon_route;
mapIcon.comment = remoteMapObject.comment;
mapIcon.setMapIconType(mapIconType);

Expand Down

0 comments on commit 6eecd30

Please sign in to comment.