• 0

    posted a message on LOTV Timer Window Skin

    Update! Got sick of this INANE api and built my own. Works better than the original and with multiple instances. No weird hacks required.

     

    const string TIMER_DIALOG_TABLE_PREFIX = "TIMER_DIALOG_TABLE_PREFIX_";
    const string TIMER_DIALOG_PARAMETER_COUNT = "TIMER_DIALOG_PARAMETER_COUNT";
    const string TIMER_DIALOG_PARAMETER_ELAPSED = "TIMER_DIALOG_PARAMETER_ELAPSED_";
    const string TIMER_DIALOG_PARAMETER_DIALOG = "TIMER_DIALOG_PARAMETER_DIALOG_";
    const string TIMER_DIALOG_PARAMETER_TIMER = "TIMER_DIALOG_PARAMETER_TIMER_";
    const string TIMER_DIALOG_PARAMETER_TIMER_LABEL = "TIMER_DIALOG_PARAMETER_TIMER_LABEL_";
    const string TIMER_DIALOG_PARAMETER_DIALOG_TITLE = "TIMER_DIALOG_PARAMETER_DIALOG_TITLE_";
    const int TIMER_DIALOG_DEFAULT_COUNT = 0;
    //Dialog Settings
    const string DIALOG_TIMER_DEFAULT_TITLE = "";
    const bool DIALOG_TIMER_INITIALLY_VISIBLE = true;
    const bool DIALOG_TIMER_COLLAPSEABLE = true;
    const bool DIALOG_TIMER_MODAL = true;
    const int DIALOG_TIMER_COLLAPSE_POSITION = DIALOG_COLLAPSED_POSITION_TOP_RIGHT;
    const int DIALOG_TIMER_WIDTH = 400;
    const int DIALOG_TIMER_HEIGHT = 120;
    const int DIALOG_TIMER_X_OFFS = 25;
    const int DIALOG_TIMER_Y_OFFS = 50;
    const int DIALOG_TIMER_ANCHOR = c_anchorTopRight;
    //Label Time Remaining Label
    const string LABEL_TIME_REMAINING_TITLE_BASE = "<1>";
    const int LABEL_TIME_REMAINING_TITLE_PRECISION = 0;
    const bool LABEL_TIME_REMAINING_INITIALLY_VISIBLE = true;
    const int LABEL_TIME_REMAINING_ANCHOR = c_anchorBottomRight;
    const int LABEL_TIME_REMAINING_WIDTH = 70;
    const int LABEL_TIME_REMAINING_HEIGHT = 20;
    const int LABEL_TIME_REMAINING_X_OFFS = 40;
    const int LABEL_TIME_REMAINING_Y_OFFS = 35;
    //Label Dialog Title
    const string LABEL_TIMER_DIALOG_TITLE_BASE = "<1>...";
    const int LABEL_TIMER_DIALOG_TITLE_PRECISION = 0;
    const bool LABEL_TIMER_DIALOG_INITIALLY_VISIBLE = true;
    const int LABEL_TIMER_DIALOG_ANCHOR = c_anchorTop;
    const int LABEL_TIMER_DIALOG_WIDTH = 250;
    const int LABEL_TIMER_DIALOG_HEIGHT = 20;
    const int LABEL_TIMER_DIALOG_X_OFFS = 0;
    const int LABEL_TIMER_DIALOG_Y_OFFS = 35;

    //variable
    const fixed TIMER_DIALOG_UPDATE_RATE = 0.5;
    const int TIMER_DIALOG_UPDATE_TYPE = c_timeGame;
    trigger timerDialogUpdate = TriggerCreate("TimerDialogUpdateActions");

    int TimerDialogGetCount(){
        return DataTableGetInt(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_COUNT);
    }

    void TimerDialogSetCount(int count){
        DataTableSetInt(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_COUNT, count);
    }

    bool TimerDialogIsElapsed(int dialog){
        return DataTableGetBool(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_ELAPSED + IntToString(dialog));
    }

    void TimerDialogSetElapsed(int dialog, bool elapsed){
        DataTableSetBool(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_ELAPSED + IntToString(dialog), elapsed);
    }

    int TimerDialogGetLabel(int dialog){
        return DataTableGetInt(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_TIMER_LABEL + IntToString(dialog));
    }

    void TimerDialogSetLabel(int dialog, int label){
        DataTableSetInt(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_TIMER_LABEL + IntToString(dialog), label);
    }

    int TimerDialogGetTitleLabel(int dialog){
        return DataTableGetInt(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_DIALOG_TITLE + IntToString(dialog));
    }

    void TimerDialogSetTitleLabel(int dialog, int label){
        DataTableSetInt(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_DIALOG_TITLE + IntToString(dialog), label);
    }

    void TimerDialogSetTitle(int dialog, playergroup group, string title){
        string titleStr = StringFormat1(LABEL_TIMER_DIALOG_TITLE_BASE, title);
        text titleText = StringToText(titleStr);
        int label = TimerDialogGetTitleLabel(dialog);

        DialogControlSetPropertyAsText (label, c_triggerControlPropertyText, group, titleText);
    }

    timer TimerDialogGetTimer(int dialog){
        return DataTableGetTimer(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_TIMER + IntToString(dialog));
    }

    void TimerDialogSetTimer(int dialog, timer time){
        DataTableSetTimer(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_TIMER + IntToString(dialog), time);
    }

    int TimerDialogGet(int index){
        return DataTableGetInt(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_DIALOG + IntToString(index));
    }

    void TimerDialogSet(int dialog, int index){
        DataTableSetInt(true, TIMER_DIALOG_TABLE_PREFIX + TIMER_DIALOG_PARAMETER_DIALOG + IntToString(index), dialog);
    }

    bool TimerDialogIsVisible(int dialog, int p){
        return DialogIsVisible(dialog, p);
    }

    void TimerDialogSetVisible(int dialog, playergroup group, bool visible){
        DialogSetVisible(dialog, group, visible);
    }

    void TimerDialogUpdate(int dialog, playergroup group){
        int label = TimerDialogGetLabel(dialog);
        timer time = TimerDialogGetTimer(dialog);
        bool elapsed = TimerDialogIsElapsed(dialog);
       fixed timerValue;
       string titleStr;
       text title;

       if(elapsed){
            timerValue = TimerGetElapsed(time);
        }
        else{
            timerValue = TimerGetRemaining(time);
        }

        titleStr = StringFormat1(LABEL_TIME_REMAINING_TITLE_BASE, FixedToString(timerValue, LABEL_TIME_REMAINING_TITLE_PRECISION));
        title = StringToText(titleStr);

        DialogControlSetPropertyAsText (label, c_triggerControlPropertyText, group, title);
    }

    int TimerDialogCreate(timer time, string title, bool visible, bool elapsed){
        playergroup group = PlayerGroupAll();
        int index = TimerDialogGetCount();
        int count = index + 1;
        int dialog = DialogCreate(DIALOG_TIMER_WIDTH, DIALOG_TIMER_HEIGHT,
            DIALOG_TIMER_ANCHOR, DIALOG_TIMER_X_OFFS, DIALOG_TIMER_Y_OFFS,
            DIALOG_TIMER_MODAL);
        int labelTimeRemaining;
        int labelTitle;
        //dialog
        TimerDialogSetVisible(dialog, group, visible);
        TimerDialogSetElapsed(dialog, elapsed);
        TimerDialogSetTimer(dialog, time);
        TimerDialogSet(dialog, index);
        TimerDialogSetCount(count);
        //label time remaining
        labelTimeRemaining = DialogControlCreate(dialog, c_triggerControlTypeLabel);
        DialogControlSetVisible(labelTimeRemaining, group, LABEL_TIME_REMAINING_INITIALLY_VISIBLE);
        DialogControlSetPosition(labelTimeRemaining, group, LABEL_TIME_REMAINING_ANCHOR, LABEL_TIME_REMAINING_X_OFFS,                                              LABEL_TIME_REMAINING_Y_OFFS);
        DialogControlSetSize(labelTimeRemaining, group, LABEL_TIME_REMAINING_WIDTH, LABEL_TIME_REMAINING_HEIGHT);
       //label title
       labelTitle = DialogControlCreate(dialog, c_triggerControlTypeLabel);
       DialogControlSetVisible(labelTitle, group, LABEL_TIMER_DIALOG_INITIALLY_VISIBLE);
       DialogControlSetPosition(labelTitle, group, LABEL_TIMER_DIALOG_ANCHOR, LABEL_TIMER_DIALOG_X_OFFS, LABEL_TIMER_DIALOG_Y_OFFS);
       DialogControlSetSize(labelTitle, group, LABEL_TIMER_DIALOG_WIDTH, LABEL_TIMER_DIALOG_HEIGHT);
       //
       TimerDialogSetLabel(dialog, labelTimeRemaining);
       TimerDialogSetTitleLabel(dialog, labelTitle);
       TimerDialogSetTitle(dialog, group, title);
       return dialog;
    }

    void InitTimerDialog(){
        TimerDialogSetCount(TIMER_DIALOG_DEFAULT_COUNT);
        TriggerAddEventTimePeriodic(timerDialogUpdate, TIMER_DIALOG_UPDATE_RATE, TIMER_DIALOG_UPDATE_TYPE);
    }

    bool TimerDialogUpdateActions(bool a, bool b){
        int count = TimerDialogGetCount();
        playergroup group = PlayerGroupAll();
        int dialog;
        int i;

     

        for(i = 0; i < count; i = i + 1){
            dialog = TimerDialogGet(i);
             TimerDialogUpdate(dialog, group);
        }

        return true;
    }

    Posted in: Triggers
  • 0

    posted a message on LOTV Timer Window Skin

    Everything we've discussed resulted in the following function. It works but only once XD. There was something missing in the function

     

    const string TIMER_DIALOG_PATH = "UIContainer\\ConsoleUIContainer\\TriggerWindowPanel\\TimerWindowTemplate";
    const string TIMER_DIALOG_ANIMATION = "HighlightStop";
    const int TIMER_DIALOG_CONTROL_TYPE = c_triggerControlTypePanel;

    int TimerWindowCreateFixed (timer lp_timer, text lp_title, bool lp_visible, bool lp_elapsed) {
        string auto2D681054_val;
        playergroup group = PlayerGroupAll();
        int window;

        // Variable Declarations
        string lv_image;

        // Variable Initialization

        // Implementation
        window = TimerWindowCreate(lp_timer, lp_title, lp_visible, lp_elapsed);
        TimerWindowShowBorder(window, true);
        TimerWindowSetImageType(window, c_timerWindowImageBackground, c_triggerImageTypeNineSlice);
        TimerWindowSetImageType(window, c_timerWindowImageProgressFill, c_triggerImageTypeNineSlice);
        TimerWindowSetImageType(window, c_timerWindowImageBorder, c_triggerImageTypeNineSlice);
        TimerWindowSetImageType(window, c_timerWindowImageProgressFrame, c_triggerImageTypeNineSlice);
        TimerWindowSetStyle(window, c_timerWindowStyleVerticalTitleTime, false);
        TimerWindowSetFixedHeight(window, 80);
        libVCUI_gf_RepositionTimerWindow(window);
        if ((libVCUI_gv_pU_TimerWindowHighlightFrame != c_invalidDialogControlId)) {
            DialogControlDestroy(libVCUI_gv_pU_TimerWindowHighlightFrame);
        }
        else {
        }
        DialogControlHookupStandard(TIMER_DIALOG_CONTROL_TYPE, TIMER_DIALOG_PATH);
        DialogControlSendAnimationEvent(window, group, TIMER_DIALOG_ANIMATION);
        libVCUI_gv_pU_TimerWindowHighlightFrame = DialogControlLastCreated();
        libVCUI_gv_pU_TimerWindowTimer = lp_timer;
        libVCUI_gv_pU_TimerWindowInDanger = false;
        TriggerEnable(libVCUI_gt_PU_TimerWindowThresholdCrossed, true);
        TriggerEnable(libVCUI_gt_PU_TimerWindowLoadUpdate, true);
        libVCUI_gf_FlashTimerWindow(8.0, false);
        auto2D681054_val = PlayerRace(1);
        if (auto2D681054_val == "Prot") {
            TimerWindowSetProgressColor(window, Color(100.00, 100.00, 0.00), 1);
        }
        else if (auto2D681054_val == "Terr") {
            TimerWindowSetProgressColor(window, Color(42.75, 68.24, 16.86), 1);
        }
        else if (auto2D681054_val == "Zerg") {
            TimerWindowSetProgressColor(window, Color(100.00, 50.20, 0.00), 1);
        }
        else {
        }

        return window;
    }

    Posted in: Triggers
  • 0

    posted a message on Timer Opacity

    In reply to Darkblizzard:

     Thx
    Posted in: Triggers
  • 0

    posted a message on Quick Functions (Cos I'm Lazeh)

    const string STR_FORMAT_BEGIN = "<";
    const string STR_FORMAT_END = ">";
    string StringFormat1(string toFormat, string arg0){
        return StringReplaceWord(toFormat, STR_FORMAT_BEGIN + "1" + STR_FORMAT_END, arg0, 1, true);
    }
    string StringFormat2(string toFormat, string arg0, string arg1){
        string format1 = StringFormat1(toFormat, arg0);
        return StringReplaceWord(format1, STR_FORMAT_BEGIN + "2" + STR_FORMAT_END, arg1, 1, true);
    }
    string StringFormat3(string toFormat, string arg0, string arg1, string arg2){
        string format2 = StringFormat2(toFormat, arg0, arg1);
        return StringReplaceWord(format2, STR_FORMAT_BEGIN + "3" + STR_FORMAT_END, arg2, 1, true);
    }
    string StringCleans(string toCleans, string cleansOf){
        return StringReplaceWord(toCleans, cleansOf, "", c_stringReplaceAll, true);
    }
    string StringJoin2(string glue, string piece0, string piece1){
        return piece0 + glue + piece1;
    }
    string StringJoin3(string glue, string piece0, string piece1, string piece2){
        return piece0 + glue + piece1 + glue + piece2;
    }
    string StringJoin4(string glue, string piece0, string piece1, string piece2, string piece3){
        return piece0 + glue + piece1 + glue + piece2 + glue + piece3;
    }
    string StringJoin5(string glue, string piece0, string piece1, string piece2, string piece3, string piece4){
        return piece0 + glue + piece1 + glue + piece2 + glue + piece3 + glue + piece4;
    }
    const string STR_COLOR_BASE = "<c val=\"<1>\"><2></c>";
    const string COLOR_RED = "FF0000";
    const string COLOR_BLUE = "151B8D";
    const string COLOR_GREEN = "00FF00";
    const string COLOR_YELLOW = "FFFF00";
    const string COLOR_ORANGE = "fe8a0e";
    const string COLOR_TEAL = "00FFFF";
    const string COLOR_PURPLE = "842DCE";
    const string COLOR_GRAY = "808080";
    string StringColor(string colored, string colorCode){
        return StringFormat2(STR_COLOR_BASE, colorCode, colored);
    }

    Posted in: Galaxy Scripting
  • 0

    posted a message on Timer Opacity

    In reply to Dorkles:

     Hey dude, think you could submit this test map? As of now I am unable to replicate thye results. Thanks.
    Posted in: Triggers
  • 0

    posted a message on LOTV Timer Window Skin

    In reply to DrSuperEvil:

     Ik how to make custom UI. That's something i was gonna try but i figured i was doing something wrong. I was hoping to make the standard one work though bc i assume it's more optimal than periodically updating a custom dialog
    Posted in: Triggers
  • 0

    posted a message on LOTV Timer Window Skin

    In reply to Talv_:

     tried using the function you linked. The Text is still very dark. It looks terrible, any way to make the text look more visible like the old sc2 timers?
    Posted in: Triggers
  • 0

    posted a message on Units "Persisting" After Removal....

    A problem I have is sometimes when I remove all units from the map they still somewhat "persist".

     

    No unit actor is visible in the game, but its almost as if a phantom unit is there who can still attack and shoot lasers...

     

    The code I have for removal is this:

     

    void PlayerRemoveUnitsAll(int player){
      unitgroup tmpGroup = UnitGroup(null, player, RegionEntireMap(), null, 0);
      UnitGroupLoopBegin(tmpGroup);
      while(!UnitGroupLoopDone()){
        UnitRemove(UnitGroupLoopCurrent());
        UnitGroupLoopStep();
      }
      UnitGroupLoopEnd();
    }

     

    Then you would call

     

    PlayerRemoveUnitsAll(c_playerAny);

     

    Edit: This seems to be inconsistent. It happens on occasion at random....

    Posted in: Triggers
  • 0

    posted a message on SC2 Bank Issue

    In reply to Talv_:

     Very informative and insightful. This my friend is research. It makes a lot of sense actually. 
    Posted in: Triggers
  • 0

    posted a message on SC2 Bank Issue

    In reply to Talv_:

     Thanks. So basically this might be a good use of the GUI then, because its nicer to have this closer to code. Its also helpful because you're telling me preload is the only way to make the bank load at all. I didn't realize that, I thought that was just for optimization (I mean, I care about optimization and planned to add it in, but I never dreamed it wouldn't allow the banks to be loaded at all!).
    Also, thanks. I really kinda dislike this bank API. I think it kinda fails at the rules of single responsibility, as BankLoad seems to also take care of creation. It should be more like "BankCreate()" "BankSave()" "BankLoad()" "BankExists()". This API isn't the best but I can at  least now see how it was intended for use. Thanks!
    Edit: Its not that bad though, I believe I was nitpicking and ranting a bit earlier. XD
    Edit: I see an advantage of using [MAP] -> [PRELOAD INFO ..]. Going to be more maintainable having the "ALL PLAYERS" option
    Edit: All seems functioning properly now.
    Posted in: Triggers
  • 0

    posted a message on SC2 Bank Issue

    In reply to maticpl:

     That's only true with the GUI preload
    Posted in: Triggers
  • 0

    posted a message on SC2 Bank Issue

    I have a script which is supposed to load a bank file if it exists and display a message to the user based on the load status.

     

    What I have is (similar to) this. I stripped it down so you don't have to view all the logic which isn't relevant to the question.

     

    Basically my problem is no matter how many times I load the map, the game outputs "New player detected. Creating new bank file!"

     

    bank b;

    int i = 1;

    playergroup playerGroup = PlayerGroupSingle(i);

     

    if(BankExists("bankname", i)){
      UIDisplayMessage(playerGroup, c_messageAreaSubtitle, StringToText("The bank exists. Welcome back!"));
      b = BankLoad("bankname", i);
      if(BankVerify(b)){
        UIDisplayMessage(playerGroup, c_messageAreaSubtitle, StringToText("The bank loaded successfully"));
      }
      else{
        UIDisplayMessage(playerGroup, c_messageAreaSubtitle, StringToText("Failed to load bank. Creating new!"));
        b = BankLoad("bankname", i);
       }
    }
    else{
      UIDisplayMessage(playerGroup, c_messageAreaSubtitle, StringToText("New player detected. Creating new bank file!"));
      b = BankLoad("bankname", i);

      BankOptionSet(b, c_bankOptionSignature, true);

      BankSave(b);
    }

    Posted in: Triggers
  • 0

    posted a message on LOTV Timer Window Skin

    In reply to Prodigy454:

     In the trigger editor I don't have 2 options to create timer windows
    Posted in: Triggers
  • 0

    posted a message on LOTV Timer Window Skin

    In reply to Prodigy454:

     Hey prodigy, I looked into what you said. Mind posting where you might find this function's definition? I opened up the code browse via the command line, no luck. Thanks!
    Posted in: Triggers
  • 0

    posted a message on LOTV Timer Window Skin

    In reply to Prodigy454:

     Mmmmm i see it's a change in the styling which was added in lotv, so if i study the new function... thanks. Will do. 
    I don't use triggers because i feel like it makes code writing slow. 
    Posted in: Triggers
  • To post a comment, please or register a new account.