Scaling Strategic Icons

Discussion in 'Mod Discussions' started by wondible, March 8, 2014.

  1. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Recap from mod ideas thread:


    Live Game? What are you trying to accomplish?
  2. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Okay, chalk that one up to JS syntax fail. The code you listed ought to be a plain value. You'd either need to assign it to a variable, or provide a function name to use it of course. It actually becomes a syntax error, however.

    So one of

    Code:
    var resetScale = function (scale) {api.arch.setIconScale(1.0) };
    Code:
    function resetScale(scale) {api.arch.setIconScale(1.0) }
  3. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    :confused: neither of the two have any effect. the game runs normall without any icon change i tryed it at scale 3.0 and 10.0

    I know I'm the broken piece in the puzzle here but what am I missing?
  4. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Well, you do have to call the function you've just defined.

    resetScale(/* parameter not used */)

    Depending on where it's used, you might want to put it on model as well.

    self.resetScale =

    or

    model.resetScale =

    Depending on where it's being defined.
  5. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    you're going to boop me on the head but here's what I tried:
    Code:
    function resetScale() {api.arch.setIconScale()
     
    model.resetScale = 10.0;
    }
    and
    Code:
    function resetScale() {api.arch.setIconScale()
    self.resetScale = 10.0;
    }
    at line 2455
  6. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    There may be some confusion between functions and values due to the game's extensive use of Knockout.

    There are a lot of different ways to organize this. To just change it once, simply call api.arch.setIconScale(10.0)

    Since the api is already available everywhere, there isn't much benefit to putting stuff on the model, unless you want to start working with settings and keybinds. However, it might look something like this:

    Code:
    model.resetScale = function() {api.arch.setIconScale(10.0)}
    model.resetScale()
    
    I haven't looked into settings manager, but a basic non-manager implementation that used KO would look like

    Code:
      model.strategicIconScale = ko.observable(1.0)
      model.strategicIconScale.subscribe(api.arch.setIconScale)
      model.strategicIconScale(2)
    
  7. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    :(
    I don't wanna have a settings entry for it.

    I just want to change in once in the code.

    Code:
     function resetScale() {
     api.arch.setIconScale(10.0);
     }
    
    I tried this. is this any better?
  8. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    As long as you call resetScale() somewhere.

    Here is a quicky mod that will do it once in code, without danger of losing live_game hacks during build updates.

    Attached Files:

  9. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    I was doing it in my own icon mod, plus am using notepad++ wich asks you if you wish to load changes to files first, so no risk of that ;)

    and thanks ! giving it a read to see what I did wrong.
  10. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    wow still can't believe it's one line.
    didn't know about that coui://ui/mods/modname/modname.js trick. that could have saved me alot of trouble testing a bunch of lines.

    was it @raevn who added that in? EDIT : realize that it's uber's original mod system with PAMM plugging into it somewhat now.
  11. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Yep, read mods/PAMM/ui/mods/ui_mod_list.js to see what it's doing with the modinfo.json paths. All the Uber scenes use this to fetch and eval those files.

    I'd normally have the mod code in a closure (function() {...})(), but there's no point here.
  12. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    it's hard to find 1:1 aspect ratio, it's never ever perfect and this isn't the bit of code that Uber is using to do the icon resize

    evidently the pngs are shrunk down, then blown back up

    so obviously it doesn't get rid off the gitchy border and 1.0 scale isn't even 1:1 aspect ratio.

    the closest i got was 1.1 (numbers two spaces after the dot are rounded)
    d1.png d2.png d3.png
    Last edited: March 8, 2014
  13. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    as a result of all this I won't be using this. :( the results are worse than with my bigger icons.

    Rule of thumb in photo editing : always downscale, never upscale

    I do have the icons ready for whenever UBER gets rid of the damn resize.

    I don't even understand why the Icons aren't part of coherent or something. they should exist in a 2D plane not a 3D one, the fact that they size up and down as you zoom out is obvious.

    I believe the icons being pixel perfect is important!
  14. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    There is definitely some black magic going on with icons. If you over over an element in the debugger, all instances get the highlight effect. It's like they are grabbing the rendered bit of one element and redrawing it N times. The few experiments I made with cursors suggest that the size of the copy region is hardcoded, but I didn't make a thorough search through all the levels of CSS and DOM.
  15. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    did you know that blackmagic is clusterfuck spelled backwards? ^^

    damn. the more we dig, the grimmer it gets.
  16. moldez

    moldez Active Member

    Messages:
    177
    Likes Received:
    110
    ... blackmagic .. like the sound of it .. just came home from a metal concert
  17. moldez

    moldez Active Member

    Messages:
    177
    Likes Received:
    110
    just shrink the damn icons down one by one and your done .. make a few tests and they are lookin acceptable
  18. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    have a read up on the thread, look at the images I posted. take screenshots and compare no scaling to scaling. you'll see the amount of loss in data is unbearably high, just look at my pictures!
  19. moldez

    moldez Active Member

    Messages:
    177
    Likes Received:
    110
    no need .. I just should not post when I´m totaly drunk :cool: .. sry
  20. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    lol why are you apologizing? It's fine man.

Share This Page