MAX_SERVERLIST_DISPLAYED = 16; function ServerListFrame_OnLoad(this) this:RegisterEvent("OPEN_SERVER_LIST"); this:RegisterEvent("SERVER_LIST_UPDATE"); end function ServerListFrame_OnEvent(this, event) if ( event == "OPEN_SERVER_LIST" ) then if ( not ServerListFrame:IsVisible() and not VivoxUserAgreement:IsVisible() ) then ServerListFrame:Show(); end elseif ( event == "SERVER_LIST_UPDATE" ) then if ( ServerListFrame:IsVisible() ) then ServerListItem_Update(); end end end function ServerListFrame_OnShow(this) RefreshServerList(); ServerListFrame.selectedName = GetCurrentServerList(); ServerListOkButton:Disable(); ServerListLastSelectedButton:SetChecked(GetSelectedRealmState()); ServerListFrame_Update(); if ( (IsBeanFanSystem() or GetLocation() == "JP" or GetLocation() == "HG" or GetLocation() == "SG") and GetCurrentLoginScreenName() == "login" ) then ServerListCancelButton:SetText(LOGIN_ACCOUNT_EXIT); else ServerListCancelButton:SetText(LOGIN_CANCEL); end end function ServerListFrame_OnUpdate(this, elapsedTime) if ( not this.update ) then this.update = 30; end if ( this.update ) then this.update = this.update - elapsedTime; if ( this.update < 0 ) then this.update = 30; RefreshServerList(); end end end function ServerListFrame_Update() local maxNums = GetNumServerList() - MAX_SERVERLIST_DISPLAYED; if ( maxNums > 0 ) then ServerListScrollBar:SetMinMaxValues(0, maxNums); ServerListScrollBar:Show(); else ServerListScrollBar:SetMinMaxValues(0, 0); ServerListScrollBar:Hide(); end ServerListItem_Update(); end function ServerListItem_Update() local numServeres = GetNumServerList(); local index = ServerListScrollBar:GetValue(); local location, name, isPVP, characters, load, isMaintain, isLogin, flagText, isTop, isNew, limitNewAccount, illegalAge; local textWidth, newIcon, hotIcon, nameStr; for i = 1, MAX_SERVERLIST_DISPLAYED do button = getglobal("ServerListItemButton"..i); if ( i + index > numServeres ) then button:Hide(); else location, name, isPVP, characters, load, isMaintain, isLogin, flagText, isTop, isNew, limitNewAccount, illegalAge = GetServerListInfo(i + index); if ( flagText and flagText ~= "" ) then getglobal(button:GetName().."LocationIcon"):Hide(); getglobal(button:GetName().."FlagBorder"):Hide(); getglobal(button:GetName().."FlagText"):Show(); getglobal(button:GetName().."FlagText"):SetText(flagText); else getglobal(button:GetName().."FlagText"):Hide(); getglobal(button:GetName().."FlagBorder"):Show(); getglobal(button:GetName().."LocationIcon"):Show(); getglobal(button:GetName().."LocationIcon"):SetTexture("Interface\\Flags\\"..location); end --[[ if ( isNew ) then name = name..LOGIN_NEW_SERVER; elseif ( isTop ) then name = name..LOGIN_TOP_SERVER; end ]]-- nameStr = getglobal(button:GetName().."Name"); nameStr:SetText(name); textWidth = nameStr:GetDisplayWidth(); if ( load == 0 ) then nameStr:SetColor(0.7, 0.7, 0.7); else nameStr:SetColor(1, 0.78, 0); end if ( isPVP ) then getglobal(button:GetName().."Type"):SetText(LOGIN_SERVER_TYPE_PVP); getglobal(button:GetName().."Type"):SetColor(1, 0, 0); else getglobal(button:GetName().."Type"):SetText(LOGIN_SERVER_TYPE_PVE); getglobal(button:GetName().."Type"):SetColor(0, 1, 0); end if ( characters > 0 ) then getglobal(button:GetName().."Character"):SetText(characters); else getglobal(button:GetName().."Character"):SetText(""); end if ( isMaintain ) then getglobal(button:GetName().."Load"):SetText(LOGIN_LOAD_MAINTAIN); if ( load < 0.3 ) then getglobal(button:GetName().."Load"):SetColor(0, 1, 0); elseif ( load < 0.6 ) then getglobal(button:GetName().."Load"):SetColor(1, 1, 0); else getglobal(button:GetName().."Load"):SetColor(1, 0, 0); end elseif ( limitNewAccount ) then getglobal(button:GetName().."Load"):SetText(LOGIN_LOAD_TYPE4); getglobal(button:GetName().."Load"):SetColor(1, 0, 0); else if ( load == 0 ) then getglobal(button:GetName().."Load"):SetText(LOGIN_LOAD_OFFLINE); getglobal(button:GetName().."Load"):SetColor(0.7, 0.7, 0.7); elseif ( load < 0.4 ) then getglobal(button:GetName().."Load"):SetText(LOGIN_LOAD_TYPE1); getglobal(button:GetName().."Load"):SetColor(0, 1, 0); elseif ( load < 0.85 ) then getglobal(button:GetName().."Load"):SetText(LOGIN_LOAD_TYPE2); getglobal(button:GetName().."Load"):SetColor(1, 1, 0); else getglobal(button:GetName().."Load"):SetText(LOGIN_LOAD_TYPE3); getglobal(button:GetName().."Load"):SetColor(1, 0, 0); end end newIcon = getglobal(button:GetName().."NewIcon"); hotIcon = getglobal(button:GetName().."HotIcon"); newIcon:Hide(); hotIcon:Hide(); if ( isNew ) then newIcon:Show(); newIcon:ClearAllAnchors(); newIcon:SetAnchor("LEFT", "LEFT", "$parentName", textWidth + 4, 0); elseif ( isTop ) then hotIcon:Show(); hotIcon:ClearAllAnchors(); hotIcon:SetAnchor("LEFT", "LEFT", "$parentName", textWidth + 4, 0); end if ( ServerListFrame.selectedName == name ) then button:LockHighlight(); if ( load == 0 ) then ServerListOkButton:Disable(); else ServerListOkButton:Enable(); end else button:UnlockHighlight(); end button.name = name; button.load = load; button.limitNewAccount = limitNewAccount; button.illegalAge = illegalAge; button:Show(); end end end function ServerListFrame_OnOk() if ( ServerListFrame.limitNewAccount ) then LoginDialog_Show("SERVER_FULL"); return; elseif ( ServerListFrame.illegalAge ) then LoginDialog_Show("SERVER_ILLEGAL_AGE"); return; end ServerListFrame:Hide(); if ( ServerListFrame.selectedName ) then ChangeServerList(ServerListFrame.selectedName); end end function ServerListFrame_OnCancel() local screenName = GetCurrentLoginScreenName(); if ( (IsBeanFanSystem() or GetLocation() == "JP" or GetLocation() == "HG" or GetLocation() == "SG") and screenName == "login" ) then AccountLogin_Exit(); else if ( screenName == "login" ) then CloseServerList(); end ServerListFrame:Hide(); end end function ServerListItem_OnClick(this) ServerListFrame.limitNewAccount = this.limitNewAccount; ServerListFrame.selectedName = this.name; ServerListFrame.illegalAge = this.illegalAge; ServerListItem_Update(); end function ServerListItem_OnDoubleClick(this) ServerListFrame.selectedName = this.name; if ( this.load > 0 ) then ServerListFrame_OnOk(); end end --==========================================-- --== Fast login added and moded functions ==-- function ServerListFrame_OnShow(this) RefreshServerList(); ServerListFrame.selectedName = GetCurrentServerList(); ServerListOkButton:Disable(); ServerListLastSelectedButton:SetChecked(GetSelectedRealmState()); ServerListFrame_Update(); if ( (IsBeanFanSystem() or GetLocation() == "JP" or GetLocation() == "HG" or GetLocation() == "SG") and GetCurrentLoginScreenName() == "login" ) then ServerListCancelButton:SetText(LOGIN_ACCOUNT_EXIT); else ServerListCancelButton:SetText(LOGIN_CANCEL); end if LogID and RealmServer and RealmServer ~= "" and RealmServer ~= " " then if GetCurrentRealm() ~= RealmServer then ChangeServerList(RealmServer) ServerListFrame:Hide(); end end end