Moving actor name/state icons & gauges during battle (solved)

I'm looking at re-positioning parts of the battle status window during battle. For example when its an actors turn their name states and gauges move to the right so it helps to display that they are currently 'active'.

mock up:
Therese would be active here.
BattleStatusEdit.jpg


I've found the code that actually draws the information and i can change the x position by changing the rect.x value. But I'm stuck trying to change the value when an actor is selected and during battle.
Spoiler: Code
Code:
Window_BattleStatus.prototype.drawItem = function(index) {
    var actor = $gameParty.battleMembers()[index];
    this.drawBasicArea(this.basicAreaRect(index), actor);
    this.drawGaugeArea(this.gaugeAreaRect(index), actor);
};

Window_BattleStatus.prototype.basicAreaRect = function(index) {
    var rect = this.itemRectForText(index);
    rect.x = 10;
    rect.width -= this.gaugeAreaWidth() + 15;
    return rect;
};

Window_BattleStatus.prototype.gaugeAreaRect = function(index) {
    var rect = this.itemRectForText(index);
    // rect.x += rect.width - this.gaugeAreaWidth();
    rect.x += 200;
    rect.width = this.gaugeAreaWidth();
    return rect;
};

Window_BattleStatus.prototype.gaugeAreaWidth = function() {
    return 330;
};

Window_BattleStatus.prototype.drawBasicArea = function(rect, actor) {
    this.drawActorName(actor, rect.x + 0, rect.y, 150);
    this.drawActorIcons(actor, rect.x + 156, rect.y, rect.width - 156);
};

Window_BattleStatus.prototype.drawGaugeArea = function(rect, actor) {
    if ($dataSystem.optDisplayTp) {
        this.drawGaugeAreaWithTp(rect, actor);
    } else {
        this.drawGaugeAreaWithoutTp(rect, actor);
    }
};

Window_BattleStatus.prototype.drawGaugeAreaWithTp = function(rect, actor) {
    this.drawActorHp(actor, rect.x + 0, rect.y, 108);
    this.drawActorMp(actor, rect.x + 123, rect.y, 96);
    this.drawActorTp(actor, rect.x + 234, rect.y, 96);
};

Window_BattleStatus.prototype.drawGaugeAreaWithoutTp = function(rect, actor) {
    this.drawActorHp(actor, rect.x + 0, rect.y, 201);
    this.drawActorMp(actor, rect.x + 216,  rect.y, 114);
};

Any idea how i can update the position for the current actor?

----------------------------------------------------------------------------------------------

Edit: I managed to figure this out 🙂 And it seems to work well. I'm not sure its the best solution though so I'd be interested to know if anyone has any ways to improve this code

StatusSlide.gif


Code:
Window_BattleStatus.prototype.basicAreaRect = function(index) {
    var rect = this.itemRectForText(index);
    rect.x = 0;
    rect.width -= this.gaugeAreaWidth() + 15;
    if (index === this._battlerIndex) {
        this._rectXOffset = 50;
    } else {
        this._rectXOffset = 0;
    }
    return rect;
};

Window_BattleStatus.prototype.drawBasicArea = function(rect, actor) {
    this.drawActorName(actor, rect.x + this._rectXOffset, rect.y, 150);
    this.drawActorIcons(actor, rect.x + 156, rect.y, rect.width - 156);
};

Window_BattleStatus.prototype.drawGaugeAreaWithoutTp = function(rect, actor) {
    this.drawActorHp(actor, rect.x + this._rectXOffset, rect.y, 201);
    this.drawActorMp(actor, rect.x + this._rectXOffset + 250,  rect.y, 114);
};

Window_BattleStatus.prototype.update = function() {
    Window_Selectable.prototype.update.call(this);
    if (BattleManager.isInputting()) {
        if (BattleManager.actor()) {
            this._battlerIndex = $gameParty.battleMembers().indexOf(BattleManager.actor());
            this.refresh();
        }
    }
    var actorCommandWindow = SceneManager._scene._actorCommandWindow;
    if (!actorCommandWindow.isOpen()) {
        this._battlerIndex = -1;
        this.refresh();
    }
};

Original thread: https://forums.rpgmakerweb.com/threads/moving-actor-name-state-icons-gauges-during-battle-solved.114224/