ID:1850857
 
Code:
client
verb
resize_map()//Add it in your Skin map Resize command field like resize-map
set hidden = 1
var s = winget(src, "MainWindow.Map", "size")// Set where the map is located
var list/dimensions = dd_text2List(s, "x")
var nx = text2num(dimensions[1]), ny = text2num(dimensions[2])
view = "[round(nx / 32)]x[round(ny / 32)]" // Set whatever View you want the player to have its set to 32. I find 48 and 64 to be good also
proc

dd_text2List(text, separator)
var/textlength = lentext(text)
var/separatorlength = lentext(separator)
var/list/textList = new /list()
var/searchPosition = 1
var/findPosition = 1
var/buggyText
while (1) // Loop forever.
findPosition = findtextEx(text, separator, searchPosition, 0)
buggyText = copytext(text, searchPosition, findPosition) // Everything from searchPosition to findPosition goes into a list element.
textList += "[buggyText]" // Working around weird problem where "text" != "text" after this copytext().

searchPosition = findPosition + separatorlength // Skip over separator.
if (findPosition == 0) // Didn't find anything at end of string so stop here.
return textList
else
if (searchPosition > textlength) // Found separator at very end of string.
textList += "" // So add empty element.
return textList


Problem description:
Hey. Im using resize_map for reizing my map. It works fine. But the problems are Huds like for example bag

        Bag
icon = 'Hud.dmi'
icon_state="Bag"
New(client/C)
screen_loc = "29:-5,1:5"

How can I set Y to increse same as the map view Y.
You'd need to change the screen location, same way that re-size_map is setting the view.
Well it depends on how you'd want the screen loc, of whatever huds to which you're referring, to change in relation to the new size of the map upon being resized.

I'd assume you'd want the huds to act in a way similar to how interface controls would (when auto-anchored) upon their parent window being re-sized, in which case you'd just have to store the previous values of the map and then upon re-sizing, work out the change from initial to final, across the x or y axis, and then apply that same change to which ever hud as you see fit. e.g. (really rough):
var/changeY = oldMapLength / newMapLength
... //skipping loads of stuff you'd have before the var definition
//and between the var definition and the line below

for(var/i = 1 to screenItems.len)
screenItems[screenItems[i]].screen_loc = "0:[oldX],0:[oldY*changeY]"

//as opposed to \
for(var/ob/Bag/item in screen)\
item.screen_loc = "0:[oldX],0:[oldY*changeY]"\
\
should be preferable btw, if you make use of some kind of var like \
var/obj/screenobjs/list/screenItems \
and just add each hud to the list like so:


Bag
icon = 'Hud.dmi'
icon_state="Bag"
New(client/C)
screen_loc = "29:-5,1:5"
screenItems["[src]"]=src


Something like that i'd imagine, although, that would probably only be an acceptable solution for when it is that you only care for shifting, it won't cover scaling.. and actually yeah, it's not so great tbh when i think about it, really, a more appropriate solution would be once that not only keeps the correct position (somewhat) on the map even after resizing, but also scales suitably when doing so. For that you'll probably want to make use of matrix or icon scale procs as well as manage the updating of bounds (this'd be necssary for the making sure underneath the mechanics also reflect the visual change i'd imagine e.g. clicks?)

So yeah i'll probably update this with something later today or something, if it is still relevant to. Or delete this if you can get better help before then :P.
Is it possible just to read from world.view what is the new max X of the view. That would be much faster. If its possible
You'd need client.view.

If client view contains an x, split and you have it. (10x15)
If client view does not contain an x, multiply by 2 and add 1. (6) same as (13x13)

As far as turbo's post on shifting, I'd store new variables to force update where it should lock, and encapsulate this in a function.

anchorX
Default: 0
Pixel number of the anchor position.
If Positive, this is pixel number from the bottom of the screen. If Negative, this is pixel from the top of the screen.

anchorY
Default: 0
Pixel number of the anchor position.
If Positive, this is pixel number from the left of the screen. If Negative, this is pixel from the right of the screen.

Sample of the function would look somewhat like this. This does not handle the current icon's size, which is something you'd probably want to adjust.
//assuming 32 pixels per tile

atom/proc/ResetAnchor(vx,vy)
var result_x, result_pixel_x, result_y, result_pixel_y

if(anchorX<0)
result_x = (vx*32)-anchorX+1
else
result_x = anchorX

result_pixel_x = result_x % 32
result_x = (result_x - result_pixel_x)/32

if(anchorY<0)
result_y = (vy*32)-anchorY+1
else
result_y = anchorY

result_pixel_y = result_y % 32
result_y = (result_y - result_pixel_y)/32

src.sreen_loc = "[result_x]:[result_pixel_x],[result_y]:[result_pixel_y]"
I manage to do something like that it works but I dont know if thats how it should be done


client
verb
resize_map()//Add it in your Skin map Resize command field like resize-map
set hidden = 1

var s = winget(src, "MainWindow.Map", "size")// Set where the map is located
var list/dimensions = dd_text2List(s, "x")
var nx = text2num(dimensions[1]), ny = text2num(dimensions[2])
view = "[round(nx / 32)]x[round(ny / 32)]" // Set whatever View you want the player to have its set to 32. I find 48 and 64 to be good also

/// Resize Bag


var/_NewY = round(nx/32)/2
var/obj/Hud/Bag/item = locate() in usr.client.screen
if(item)
item.screen_loc = "29+[_NewY]:-5,1:5"
if you want to operate on screen_loc directly, you'll need to break down the parts.