From dc5a401d8bde2f39b811e5e86e0146ba88a05537 Mon Sep 17 00:00:00 2001 From: Buckaroo Banzai <39065740+BuckarooBanzay@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:40:36 +0200 Subject: [PATCH] Fork 20240605 um area forsale (#379) * Add For Sale Sings for Unified Money * Change popup and icon size * Revert icon size * Add For Sale Sign into searches * Fix syntax * Minor display change * Skip unconfigured for sale signs --------- Co-authored-by: 1F616EMO --- app/config.go | 63 +++++++++--------- app/types.go | 63 +++++++++--------- doc/license.md | 4 ++ mapobject/setup.go | 5 ++ mapobject/um_area_forsale.go | 26 ++++++++ public/js/components/Search.js | 3 +- public/js/components/SearchResult.js | 6 ++ public/js/map/Overlaysetup.js | 10 ++- .../UnifiedMoneyAreaForSaleOverlay.js | 29 ++++++++ public/pics/um_area_forsale_sign_alpha.png | Bin 0 -> 239 bytes 10 files changed, 145 insertions(+), 64 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 94f9789..1d11efb 100644 --- a/app/config.go +++ b/app/config.go @@ -58,37 +58,38 @@ 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, - Phonograph: 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, + Phonograph: true, } mapblockaccessor := MapBlockAccessorConfig{ diff --git a/app/types.go b/app/types.go index 760099e..1576361 100644 --- a/app/types.go +++ b/app/types.go @@ -34,37 +34,38 @@ 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"` - Phonograph bool `json:"phonograph"` + 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"` + Phonograph bool `json:"phonograph"` + UnifiefMoneyAreaForSale bool `json:"um_area_forsale"` } type WebApiConfig struct { diff --git a/doc/license.md b/doc/license.md index d3d1ec8..1970901 100644 --- a/doc/license.md +++ b/doc/license.md @@ -76,3 +76,7 @@ * phonograph_node_temp.png * License: CC By-SA 4.0 * Source: [phonograph](https://github.com/C-C-Minetest-Server/phonograph/) + +* 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 d5d215f..e5350cc 100644 --- a/mapobject/setup.go +++ b/mapobject/setup.go @@ -197,5 +197,10 @@ func Setup(ctx *app.App) { l.AddMapObject("phonograph:phonograph", &Phonograph{}) } + //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..328f0a0 --- /dev/null +++ b/mapobject/um_area_forsale.go @@ -0,0 +1,26 @@ +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) + + 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 + o.Attributes["price"] = md["price"] + o.Attributes["description"] = md["description"] + + return o +} diff --git a/public/js/components/Search.js b/public/js/components/Search.js index 668db86..f4f818e 100644 --- a/public/js/components/Search.js +++ b/public/js/components/Search.js @@ -30,7 +30,8 @@ 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) ]; 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){ diff --git a/public/js/map/Overlaysetup.js b/public/js/map/Overlaysetup.js index 094a318..7fad415 100644 --- a/public/js/map/Overlaysetup.js +++ b/public/js/map/Overlaysetup.js @@ -24,6 +24,7 @@ import TrainsignalOverlay from './overlays/TrainsignalOverlay.js'; import SignOverlay from './overlays/SignOverlay.js'; import AirUtilsPlanesOverlay from "./overlays/AirUtilsPlanesOverlay.js"; import PhonographOverlay from "./overlays/PhonographOverlay.js"; +import UnifiedMoneyAreaForSaleOverlay from './overlays/UnifiedMoneyAreaForSaleOverlay.js'; export default function(cfg, map, overlays, wsChannel){ @@ -210,8 +211,15 @@ export default function(cfg, map, overlays, wsChannel){ if (cfg.mapobjects.phonograph) { overlays.Phonographs = new PhonographOverlay(); - if (isDefault("phonograph")) { + if (isDefault("Phonographs")) { map.addLayer(overlays.Phonographs); } } + if (cfg.mapobjects.um_area_forsale) { + overlays["Area For Sale"] = new UnifiedMoneyAreaForSaleOverlay(); + if (isDefault("Area For Sale")) { + map.addLayer(overlays["Area For Sale"]); + } + } + } diff --git a/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js b/public/js/map/overlays/UnifiedMoneyAreaForSaleOverlay.js new file mode 100644 index 0000000..4b38048 --- /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 () { + 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

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

" + + "Owner: " + HtmlSanitizer.SanitizeHtml(obj.attributes.owner) + "
" + + "Area ID(s): " + 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`<