From d6e65af8f2151eab4bf5ec12beb9394f1130d20a Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Wed, 5 Jun 2024 18:40:04 +0800 Subject: [PATCH 1/7] Add For Sale Sings for Unified Money --- app/config.go | 61 +++++++++--------- app/types.go | 61 +++++++++--------- doc/license.md | 4 ++ mapobject/setup.go | 5 ++ mapobject/um_area_forsale.go | 22 +++++++ public/js/map/Overlaysetup.js | 8 +++ .../UnifiedMoneyAreaForSaleOverlay.js | 29 +++++++++ public/pics/um_area_forsale_sign_alpha.png | Bin 0 -> 239 bytes 8 files changed, 130 insertions(+), 60 deletions(-) create mode 100644 mapobject/um_area_forsale.go create mode 100644 public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js create mode 100644 public/pics/um_area_forsale_sign_alpha.png diff --git a/app/config.go b/app/config.go index a2b5675..e05ffe9 100644 --- a/app/config.go +++ b/app/config.go @@ -58,36 +58,37 @@ func ParseConfig(filename string) (*Config, error) { } mapobjs := MapObjectConfig{ - Areas: true, - Bones: true, - Protector: true, - XPProtector: true, - PrivProtector: true, - TechnicQuarry: true, - TechnicSwitch: true, - TechnicAnchor: true, - TechnicReactor: true, - LuaController: true, - Digiterms: true, - Digilines: true, - Travelnet: true, - MapserverPlayer: true, - MapserverPOI: true, - MapserverLabel: true, - MapserverTrainline: true, - MapserverBorder: true, - TileServerLegacy: true, - Mission: true, - Jumpdrive: true, - Smartshop: true, - Fancyvend: true, - ATM: true, - Train: true, - TrainSignal: true, - Minecart: false, - Locator: false, - Signs: true, - MapserverAirutils: true, + Areas: true, + Bones: true, + Protector: true, + XPProtector: true, + PrivProtector: true, + TechnicQuarry: true, + TechnicSwitch: true, + TechnicAnchor: true, + TechnicReactor: true, + LuaController: true, + Digiterms: true, + Digilines: true, + Travelnet: true, + MapserverPlayer: true, + MapserverPOI: true, + MapserverLabel: true, + MapserverTrainline: true, + MapserverBorder: true, + TileServerLegacy: true, + Mission: true, + Jumpdrive: true, + Smartshop: true, + Fancyvend: true, + ATM: true, + Train: true, + TrainSignal: true, + Minecart: false, + Locator: false, + Signs: true, + MapserverAirutils: true, + UnifiefMoneyAreaForSale: true, } mapblockaccessor := MapBlockAccessorConfig{ diff --git a/app/types.go b/app/types.go index df542de..0eb4f93 100644 --- a/app/types.go +++ b/app/types.go @@ -34,36 +34,37 @@ type MapBlockAccessorConfig struct { } type MapObjectConfig struct { - Areas bool `json:"areas"` - Bones bool `json:"bones"` - Protector bool `json:"protector"` - XPProtector bool `json:"xpprotector"` - PrivProtector bool `json:"privprotector"` - TechnicQuarry bool `json:"technic_quarry"` - TechnicSwitch bool `json:"technic_switch"` - TechnicAnchor bool `json:"technic_anchor"` - TechnicReactor bool `json:"technic_reactor"` - LuaController bool `json:"luacontroller"` - Digiterms bool `json:"digiterms"` - Digilines bool `json:"digilines"` - Travelnet bool `json:"travelnet"` - MapserverPlayer bool `json:"mapserver_player"` - MapserverPOI bool `json:"mapserver_poi"` - MapserverLabel bool `json:"mapserver_label"` - MapserverTrainline bool `json:"mapserver_trainline"` - MapserverBorder bool `json:"mapserver_border"` - TileServerLegacy bool `json:"tileserverlegacy"` - Mission bool `json:"mission"` - Jumpdrive bool `json:"jumpdrive"` - Smartshop bool `json:"smartshop"` - Fancyvend bool `json:"fancyvend"` - ATM bool `json:"atm"` - Train bool `json:"train"` - TrainSignal bool `json:"trainsignal"` - Minecart bool `json:"minecart"` - Locator bool `json:"locator"` - Signs bool `json:"signs"` - MapserverAirutils bool `json:"mapserver_airutils"` + Areas bool `json:"areas"` + Bones bool `json:"bones"` + Protector bool `json:"protector"` + XPProtector bool `json:"xpprotector"` + PrivProtector bool `json:"privprotector"` + TechnicQuarry bool `json:"technic_quarry"` + TechnicSwitch bool `json:"technic_switch"` + TechnicAnchor bool `json:"technic_anchor"` + TechnicReactor bool `json:"technic_reactor"` + LuaController bool `json:"luacontroller"` + Digiterms bool `json:"digiterms"` + Digilines bool `json:"digilines"` + Travelnet bool `json:"travelnet"` + MapserverPlayer bool `json:"mapserver_player"` + MapserverPOI bool `json:"mapserver_poi"` + MapserverLabel bool `json:"mapserver_label"` + MapserverTrainline bool `json:"mapserver_trainline"` + MapserverBorder bool `json:"mapserver_border"` + TileServerLegacy bool `json:"tileserverlegacy"` + Mission bool `json:"mission"` + Jumpdrive bool `json:"jumpdrive"` + Smartshop bool `json:"smartshop"` + Fancyvend bool `json:"fancyvend"` + ATM bool `json:"atm"` + Train bool `json:"train"` + TrainSignal bool `json:"trainsignal"` + Minecart bool `json:"minecart"` + Locator bool `json:"locator"` + Signs bool `json:"signs"` + MapserverAirutils bool `json:"mapserver_airutils"` + UnifiefMoneyAreaForSale bool `json:"um_area_forsale"` } type WebApiConfig struct { diff --git a/doc/license.md b/doc/license.md index c40f38b..782e936 100644 --- a/doc/license.md +++ b/doc/license.md @@ -72,3 +72,7 @@ * unifieddyes_palette_extended.png * GPL 2.0 * Source: https://gitlab.com/VanessaE/unifieddyes + +* um_area_forsale_sign_alpha.png + * By Gabriel PĂ©rez-Cerezo; AGPL 3.0 + * Modified from https://github.com/C-C-Minetest-Server/um_area_forsale/blob/main/textures/um_area_forsale_sign.png diff --git a/mapobject/setup.go b/mapobject/setup.go index 525328d..78b37c3 100644 --- a/mapobject/setup.go +++ b/mapobject/setup.go @@ -184,5 +184,10 @@ func Setup(ctx *app.App) { l.AddMapObject("default:sign_wall_steel", &SignBlock{Material: "steel"}) } + //For Sale Sign for Unified Money + if ctx.Config.MapObjects.UnifiefMoneyAreaForSale { + l.AddMapObject("um_area_forsale:for_sale_sign", &UnifiefMoneyAreaForSale{}) + } + ctx.MapBlockAccessor.Eventbus.AddListener(&l) } diff --git a/mapobject/um_area_forsale.go b/mapobject/um_area_forsale.go new file mode 100644 index 0000000..95f5ad3 --- /dev/null +++ b/mapobject/um_area_forsale.go @@ -0,0 +1,22 @@ +package mapobject + +import ( + "mapserver/mapobjectdb" + "mapserver/types" + + "github.com/minetest-go/mapparser" +) + +type UnifiefMoneyAreaForSale struct{} + +func (this *UnifiefMoneyAreaForSale) onMapObject(mbpos *types.MapBlockCoords, x, y, z int, block *mapparser.MapBlock) *mapobjectdb.MapObject { + md := block.Metadata.GetMetadata(x, y, z) + + o := mapobjectdb.NewMapObject(mbpos, x, y, z, "um_area_forsale") + o.Attributes["owner"] = md["owner"] + o.Attributes["id"] = md["id"] // ", " seperated + o.Attributes["price"] = md["price"] + o.Attributes["description"] = md["description"] + + return o +} diff --git a/public/js/map/Overlaysetup.js b/public/js/map/Overlaysetup.js index c155dd3..74578e8 100644 --- a/public/js/map/Overlaysetup.js +++ b/public/js/map/Overlaysetup.js @@ -23,6 +23,7 @@ import TrainOverlay from './overlays/TrainOverlay.js'; import TrainsignalOverlay from './overlays/TrainsignalOverlay.js'; import SignOverlay from './overlays/SignOverlay.js'; import AirUtilsPlanesOverlay from "./overlays/AirUtilsPlanesOverlay.js"; +import UnifiedMoneyAreaForSaleOverlay from './overlays/UnifiedMoneyAreaForSaleOverlay.js'; export default function(cfg, map, overlays, wsChannel){ @@ -207,4 +208,11 @@ export default function(cfg, map, overlays, wsChannel){ } } + if (cfg.mapobjects.um_area_forsale) { + overlays.UnifiedMoneyAreaForSale = new UnifiedMoneyAreaForSaleOverlay(); + if (isDefault("um_area_forsale")) { + map.addLayer(overlays.UnifiedMoneyAreaForSale); + } + } + } diff --git a/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js b/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js new file mode 100644 index 0000000..7aa0b2d --- /dev/null +++ b/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js @@ -0,0 +1,29 @@ +import AbstractIconOverlay from './AbstractIconOverlay.js'; +import {HtmlSanitizer} from '../../lib/HtmlSanitizer.js'; + +export default AbstractIconOverlay.extend({ + initialize: function() { + AbstractIconOverlay.prototype.initialize.call(this, "um_area_forsale"); + }, + + getMaxDisplayedZoom: function(){ + return 8; + }, + + getIcon: function(obj){ + return L.icon({ + iconUrl: "pics/um_area_forsale_sign_alpha.png", + iconSize: [32, 32], + iconAnchor: [16, 16], + popupAnchor: [0, -16] + }); + }, + + createPopup: function(obj){ + return "

Area for sale


" + + "Description: $" + HtmlSanitizer.SanitizeHtml(obj.attributes.description || "N/A") + "
" + + "Owner: " + HtmlSanitizer.SanitizeHtml(obj.attributes.owner) + "
" + + "Area IDs: " + HtmlSanitizer.SanitizeHtml(obj.attributes.id) + "
" + + "Price: $" + HtmlSanitizer.SanitizeHtml(obj.attributes.price) + "
"; + } +}); diff --git a/public/pics/um_area_forsale_sign_alpha.png b/public/pics/um_area_forsale_sign_alpha.png new file mode 100644 index 0000000000000000000000000000000000000000..799c1e7bf29a6ad9af526f127a9cfc5a4ed4cee7 GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvl>na**Vas%#$@A#bsozaz1p*F zgY1>VomGL7mCeO<2?qcF|NqS(euQYMT}F-*wuJi4FuZm`< Date: Wed, 5 Jun 2024 18:46:42 +0800 Subject: [PATCH 2/7] Change popup and icon size --- public/js/map/Overlaysetup.js | 4 ++-- .../overlays/UnifiedMoneyAreaForSaleOverlay.js | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/public/js/map/Overlaysetup.js b/public/js/map/Overlaysetup.js index 74578e8..d8ef86d 100644 --- a/public/js/map/Overlaysetup.js +++ b/public/js/map/Overlaysetup.js @@ -209,9 +209,9 @@ export default function(cfg, map, overlays, wsChannel){ } if (cfg.mapobjects.um_area_forsale) { - overlays.UnifiedMoneyAreaForSale = new UnifiedMoneyAreaForSaleOverlay(); + overlays["Area For Sale"] = new UnifiedMoneyAreaForSaleOverlay(); if (isDefault("um_area_forsale")) { - map.addLayer(overlays.UnifiedMoneyAreaForSale); + map.addLayer(overlays["Area For Sale"]); } } diff --git a/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js b/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js index 7aa0b2d..9a29870 100644 --- a/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js +++ b/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js @@ -2,26 +2,26 @@ import AbstractIconOverlay from './AbstractIconOverlay.js'; import {HtmlSanitizer} from '../../lib/HtmlSanitizer.js'; export default AbstractIconOverlay.extend({ - initialize: function() { + initialize: function () { AbstractIconOverlay.prototype.initialize.call(this, "um_area_forsale"); }, - getMaxDisplayedZoom: function(){ + getMaxDisplayedZoom: function () { return 8; }, - getIcon: function(obj){ + getIcon: function (obj) { return L.icon({ iconUrl: "pics/um_area_forsale_sign_alpha.png", - iconSize: [32, 32], - iconAnchor: [16, 16], - popupAnchor: [0, -16] + iconSize: [16, 16], + iconAnchor: [16, 16], + popupAnchor: [0, -16] }); }, - createPopup: function(obj){ - return "

Area for sale


" + - "Description: $" + HtmlSanitizer.SanitizeHtml(obj.attributes.description || "N/A") + "
" + + createPopup: function (obj) { + return "

Area for sale

" + + "
" + HtmlSanitizer.SanitizeHtml(obj.attributes.description || "No Description") + "

" + "Owner: " + HtmlSanitizer.SanitizeHtml(obj.attributes.owner) + "
" + "Area IDs: " + HtmlSanitizer.SanitizeHtml(obj.attributes.id) + "
" + "Price: $" + HtmlSanitizer.SanitizeHtml(obj.attributes.price) + "
"; From 134eee104f75e52827d573a381148f43ddf6245a Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Wed, 5 Jun 2024 18:47:00 +0800 Subject: [PATCH 3/7] Revert icon size --- public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js b/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js index 9a29870..ce1daed 100644 --- a/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js +++ b/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js @@ -13,7 +13,7 @@ export default AbstractIconOverlay.extend({ getIcon: function (obj) { return L.icon({ iconUrl: "pics/um_area_forsale_sign_alpha.png", - iconSize: [16, 16], + iconSize: [32, 32], iconAnchor: [16, 16], popupAnchor: [0, -16] }); From cad800fbeee760907422e3f23ac8611dd7f8436d Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Wed, 5 Jun 2024 18:50:22 +0800 Subject: [PATCH 4/7] Add For Sale Sign into searches --- public/js/components/Search.js | 1 + public/js/components/SearchResult.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/public/js/components/Search.js b/public/js/components/Search.js index 668db86..725661c 100644 --- a/public/js/components/Search.js +++ b/public/js/components/Search.js @@ -31,6 +31,7 @@ function search(query){ searchFor("label", "text", query), searchFor("digiterm", "display_text", query), searchFor("digilinelcd", "text", query) + searchFor("um_area_forsale", "description", query) ]; Promise.all(prom_list) diff --git a/public/js/components/SearchResult.js b/public/js/components/SearchResult.js index 1ac8c51..aec19bd 100644 --- a/public/js/components/SearchResult.js +++ b/public/js/components/SearchResult.js @@ -88,6 +88,12 @@ export default { ]); } + // For Sale Sign + if (obj.type == "um_area_forsale"){ + description = m("span", obj.attributes.description || "No Description"); + type = m("img", { src: "pics/um_area_forsale_sign_alpha.png" }); + } + //shop if (obj.type == "shop") { if (obj.attributes.stock == 0){ From 797558db0010617720315ac7889d3707a00686ea Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Wed, 5 Jun 2024 18:51:33 +0800 Subject: [PATCH 5/7] Fix syntax --- public/js/components/Search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/components/Search.js b/public/js/components/Search.js index 725661c..f4f818e 100644 --- a/public/js/components/Search.js +++ b/public/js/components/Search.js @@ -30,7 +30,7 @@ function search(query){ searchFor("locator", "name", query), searchFor("label", "text", query), searchFor("digiterm", "display_text", query), - searchFor("digilinelcd", "text", query) + searchFor("digilinelcd", "text", query), searchFor("um_area_forsale", "description", query) ]; From 181d62639f4a92c85c538e95b28fb1a07d0367a5 Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Wed, 5 Jun 2024 19:00:13 +0800 Subject: [PATCH 6/7] Minor display change --- public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js b/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js index ce1daed..ec0897d 100644 --- a/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js +++ b/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js @@ -20,10 +20,10 @@ export default AbstractIconOverlay.extend({ }, createPopup: function (obj) { - return "

Area for sale

" + + return "

Area For Sale

" + "
" + HtmlSanitizer.SanitizeHtml(obj.attributes.description || "No Description") + "

" + "Owner: " + HtmlSanitizer.SanitizeHtml(obj.attributes.owner) + "
" + - "Area IDs: " + HtmlSanitizer.SanitizeHtml(obj.attributes.id) + "
" + + "Area ID(s): " + HtmlSanitizer.SanitizeHtml(obj.attributes.id) + "
" + "Price: $" + HtmlSanitizer.SanitizeHtml(obj.attributes.price) + "
"; } }); From afd71ffcfd9a204a0d76bdd6aadb85bd06a49391 Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Wed, 5 Jun 2024 23:34:41 +0800 Subject: [PATCH 7/7] Skip unconfigured for sale signs --- mapobject/um_area_forsale.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mapobject/um_area_forsale.go b/mapobject/um_area_forsale.go index 95f5ad3..328f0a0 100644 --- a/mapobject/um_area_forsale.go +++ b/mapobject/um_area_forsale.go @@ -12,6 +12,10 @@ type UnifiefMoneyAreaForSale struct{} func (this *UnifiefMoneyAreaForSale) onMapObject(mbpos *types.MapBlockCoords, x, y, z int, block *mapparser.MapBlock) *mapobjectdb.MapObject { md := block.Metadata.GetMetadata(x, y, z) + if _, ok := md["id"]; !ok { + return nil + } + o := mapobjectdb.NewMapObject(mbpos, x, y, z, "um_area_forsale") o.Attributes["owner"] = md["owner"] o.Attributes["id"] = md["id"] // ", " seperated