--MOVE THIS ELSEWHERE!!!
--ISN'T THIS ALREADY IN game_damage.LUA?!?!?!?
function p.calc_dmg_from_player(raw)
    pre = raw
    if( ga_get_b("xar.difficulty.easy_2") ) then pre = math.floor(raw * 4.0) end
    if( ga_get_b("xar.difficulty.easy_1") ) then pre = math.floor(raw * 2.0) end
    if( ga_get_b("xar.difficulty.hard_1") ) then pre = math.floor(raw * 0.5) end
    if( ga_get_b("xar.difficulty.hard_2") ) then pre = math.floor(raw * 0.25) end
    if( ga_get_b("xar.difficulty.hard_3") ) then pre = math.floor(raw * 0.125) end
    if( ga_get_b("xar.difficulty.hard_4") ) then pre = math.floor(raw * 0.125) end
    if( pre < 0.5 ) then pre = 1.0 end
    return pre
end

function p.round(num, numDecimalPlaces)
  local mult = 10^(numDecimalPlaces or 0)
  return math.floor(num * mult + 0.5) / mult
end

--Will return either green or yellow,
--depending on whether num == max_num.
function p.max_color(num_var, max_num)
    num = ga_get_i(num_var)
    -- max_num = ga_get_i(max_num_var)
    if( num >= max_num ) then return "^x00ff00"
    else return "^xffff00" end
end

function p.__render(wid)
    ga_win_set_background(wid, std.vec(0.0, 0.0, 0.0), 0.95)

    ga_win_set_char_size(wid, 0.02, 0.04)
    ga_win_txt_center(wid, 0.92, "INDIVIDUAL WEAPON STATS")

    ga_win_set_char_size(wid, 0.01, 0.02)
    ga_win_txt_center(wid, 0.88, "TYPE A WEAPON NUMBER OR USE LEFT / RIGHT ARROWS")

    -- if not ga_exists("temp.xar.stats2.win_num") then
    --     ga_create_i("temp.xar.stats2.win_num")
    --     ga_set_i("temp.xar.stats2.win_num", 1)
    -- end
    ga_init_i("temp.xar.stats3.win_num", 1)

    local win_num = ga_get_i("temp.xar.stats3.win_num")

    local min_x = 0.3
    local cur_y = 0.8
    local step_y = 0.04

    if win_num == 1 then
        ga_win_txt(wid, min_x,cur_y, "WEAPON #1 (Plasma)")

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "MAX AMMO: " ..
            game_str.add_commas( game_wep_modes.get_ammo_max(1) ) )

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "REGENERATION: " ..
            p.round(1.0 / game_wep_modes.get_ammo_regen_period(1), 2) .. " per sec" )        

        cur_y = cur_y - step_y
        local fire_rate = 1.0 / game_wep_modes.get_fire_period(1,1)
        local mcolor = p.max_color(
            "xar.player.gun1.fire_period_level",
            game_wep_modes.get_fire_period_level_max(1))
        ga_win_txt(wid, min_x,cur_y, mcolor .. "FIRE RATE: " ..
            p.round(fire_rate,2) .. " per sec" ) 

        --Mode 1 (Primary).
        if game_wep_modes.get_equipped(1,1) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Basic High DPA): " ..
                game_str.add_commas(
                p.calc_dmg_from_player( game_wep_modes.get_curved_damage(1,1) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Basic High DPA): " ..
                game_str.add_commas( math.floor(p.round( game_wep_modes.get_dps(1,1)), 2) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Basic High DPA): " ..
                game_str.add_commas( math.floor( game_wep_modes.get_dpa(1,1) ) ) )

            cur_y = cur_y - step_y
            local mcolor = p.max_color(
                "xar.player.gun1.speed_level",
                game_wep_modes.get_vel_level_max(1))
            local speed1 = game_wep_modes.get_vel(1,1)
            ga_win_txt(wid, min_x,cur_y, mcolor .. "VELOCITY (Basic High DPA): " .. speed1 .. " per sec")
        end

        --Mode 2 (Secondary).
        if game_wep_modes.get_equipped(1,2) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Rapid Fire): " ..
                game_str.add_commas(
                p.calc_dmg_from_player( game_wep_modes.get_curved_damage(1,2) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Rapid Fire): " ..
                game_str.add_commas( math.floor( p.round( game_wep_modes.get_dps(1,2), 2) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Rapid Fire): " ..
                game_str.add_commas( math.floor( game_wep_modes.get_dpa(1,2)) ) )

            cur_y = cur_y - step_y
            local mcolor = p.max_color(
                "xar.player.gun1.speed_level",
                game_wep_modes.get_vel_level_max(1))
            local speed2 = game_wep_modes.get_vel(1,2)
            ga_win_txt(wid, min_x,cur_y, mcolor .. "VELOCITY (Rapid Fire): " .. speed2 .. " per sec")
        end

        --Mode 3.
        if game_wep_modes.get_equipped(1,3) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Plasma Shotgun): " ..
                game_str.add_commas(
                p.calc_dmg_from_player( game_wep_modes.get_curved_damage(1,3) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Plasma Shotgun): " ..
                game_str.add_commas( math.floor( p.round( game_wep_modes.get_dps(1,3), 2) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Plasma Shotgun): " ..
                game_str.add_commas( math.floor( game_wep_modes.get_dpa(1,3)) ) )

            cur_y = cur_y - step_y
            local mcolor = p.max_color(
                "xar.player.gun1.speed_level",
                game_wep_modes.get_vel_level_max(1))
            local speed2 = game_wep_modes.get_vel(1,3)
            ga_win_txt(wid, min_x,cur_y, mcolor .. "VELOCITY (Plasma Shotgun): " .. speed2 .. " per sec")
        end

        --Mode 4.
        if game_wep_modes.get_equipped(1,4) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Hyper Rapid Fire): " ..
                game_str.add_commas(
                p.calc_dmg_from_player( game_wep_modes.get_curved_damage(1,4) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Hyper Rapid Fire): " ..
                game_str.add_commas( math.floor( p.round( game_wep_modes.get_dps(1,4), 2) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Hyper Rapid Fire): " ..
                game_str.add_commas( math.floor( game_wep_modes.get_dpa(1,4)) ) )

            cur_y = cur_y - step_y
            local mcolor = p.max_color(
                "xar.player.gun1.speed_level",
                game_wep_modes.get_vel_level_max(1))
            local speed2 = game_wep_modes.get_vel(1,4)
            ga_win_txt(wid, min_x,cur_y, mcolor .. "VELOCITY (Hyper Rapid Fire): " .. speed2 .. " per sec")
        end

        --Mode 5.
        if game_wep_modes.get_equipped(1,5) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Lightning Rifle): " ..
                game_str.add_commas(
                p.calc_dmg_from_player( game_wep_modes.get_curved_damage(1,5) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Lightning Rifle): " ..
                game_str.add_commas( math.floor( p.round( game_wep_modes.get_dps(1,5), 2) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Lightning Rifle): " ..
                game_str.add_commas( math.floor( game_wep_modes.get_dpa(1,5)) ) )
        end
    end

    if win_num == 2 then
        ga_win_txt(wid, min_x,cur_y, "WEAPON #2 (Cannon)")

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "MAX AMMO: " ..
            game_str.add_commas( game_wep_modes.get_ammo_max(2) ) )

        cur_y = cur_y - step_y
        local fire_rate = 1.0 / game_wep_modes.get_fire_period(2,1)
        local mcolor = p.max_color(
            "xar.player.gun2.fire_period_level",
            game_wep_modes.get_fire_period_level_max(2))
        ga_win_txt(wid, min_x,cur_y, mcolor .. "FIRE RATE: " .. p.round(fire_rate,2) .. " per sec")

        --Mode 1.
        if game_wep_modes.get_equipped(2,1) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local damage = p.calc_dmg_from_player(
                game_wep_modes.get_curved_damage(2,1))
            ga_win_txt(wid, min_x,cur_y,
                "DAMAGE (Blunderbuss): " .. game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Blunderbuss): " ..
                game_str.add_commas( math.floor( p.round(game_wep_modes.get_dps(2,1), 2) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Blunderbuss): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_dpa(2,1)) ) )

            cur_y = cur_y - step_y
            local mcolor = p.max_color(
                "xar.player.gun2.speed_level",
                game_wep_modes.get_vel_level_max(2))
            local speed1 = game_wep_modes.get_vel(2,1)
            ga_win_txt(wid, min_x,cur_y, mcolor .. "VELOCITY (Blunderbuss): " .. speed1 .. " per sec")
        end

        --Mode 2.
        if game_wep_modes.get_equipped(2,2) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local damage = p.calc_dmg_from_player(
                game_wep_modes.get_curved_damage(2,2))
            ga_win_txt(wid, min_x,cur_y,
                "DAMAGE (Tommy Gun): " .. game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Tommy Gun): " ..
                game_str.add_commas( math.floor( p.round(game_wep_modes.get_dps(2,2), 2) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Tommy Gun): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_dpa(2,2)) ) )

            cur_y = cur_y - step_y
            local mcolor = p.max_color(
                "xar.player.gun2.speed_level",
                game_wep_modes.get_vel_level_max(2))
            local speed1 = game_wep_modes.get_vel(2,2)
            ga_win_txt(wid, min_x,cur_y, mcolor .. "VELOCITY (Tommy Gun): " .. speed1 .. " per sec")
        end

        --Mode 3.
        if game_wep_modes.get_equipped(2,3) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local damage = p.calc_dmg_from_player(
                game_wep_modes.get_curved_damage(2,3))
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Chaining Cannon Ball): " ..
                game_str.add_commas( math.floor(damage) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Chaining Cannon Ball): " ..
                game_str.add_commas( math.floor( p.round(game_wep_modes.get_dps(2,3), 2) ) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Chaining Cannon Ball): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_dpa(2,3)) ) )

            cur_y = cur_y - step_y
            local mcolor = p.max_color(
                "xar.player.gun2.speed_level",
                game_wep_modes.get_vel_level_max(2))
            local speed2 = game_wep_modes.get_vel(2,3)
            ga_win_txt(wid, min_x,cur_y, mcolor .. "VELOCITY (Chaining Cannon Ball): " .. speed2 .. " per sec")
        end

        cur_y = cur_y - step_y
        cur_y = cur_y - step_y
        if not game_can_use.main(2) then
            ga_win_txt(wid, min_x,cur_y, "^xff0000YOU CANNOT USE THIS WEAPON BECAUSE YOU ")
            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xff0000HAVE NOT PICKED UP AN UPGRADE FOR IT")
        end
    end

    if win_num == 3 then
        ga_win_txt(wid, min_x,cur_y, "WEAPON #3 (Laser)")

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "MAX AMMO: " ..
           game_str.add_commas( game_wep_modes.get_ammo_max(3) ) )
        cur_y = cur_y - step_y

        local fire_rate = 1.0 / game_wep_modes.get_fire_period(3,1)
        ga_win_txt(wid, min_x,cur_y, "FIRE RATE: " .. p.round(fire_rate,2) .. " per sec")
        
        --Ok to print this.
        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "^xff00ff" .. "SPECIAL DAMAGE FACTOR: " ..
            ga_get_i("xar.player.gun3.num_level") + 1)

        --Primary only.
        cur_y = cur_y - step_y

        cur_y = cur_y - step_y
        local raw_damage = game_wep_modes.get_curved_damage(3,1)
        local damage = p.calc_dmg_from_player(raw_damage)
        ga_win_txt(wid, min_x,cur_y, "DAMAGE (primary): " ..
            game_str.add_commas(damage) )

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "DPS (primary): " ..
            game_str.add_commas( math.floor( p.round(game_wep_modes.get_dps(3,1), 2) ) ))

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "DPA (primary): " ..
            game_str.add_commas( math.floor(game_wep_modes.get_dpa(3,1)) ) )

        cur_y = cur_y - step_y
        local freeze_time = game_wep_modes.get_freeze_length(3,1)
        local mcolor = p.max_color(
            "xar.player.gun3.freeze_time_level",
            game_wep_modes.get_freeze_length_level_max(3))
        ga_win_txt(wid, min_x,cur_y, mcolor .. "FREEZE TIME: "
            .. p.round(freeze_time,2) .. " sec")

        --Secondary only.
        cur_y = cur_y - step_y

        cur_y = cur_y - step_y
        local raw_damage = game_wep_modes.get_curved_damage(3,2)
        local damage = p.calc_dmg_from_player(raw_damage)
        ga_win_txt(wid, min_x,cur_y, "DAMAGE (secondary): " ..
            game_str.add_commas(damage) )

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "DPS (secondary): " .. 
            game_str.add_commas( math.floor( game_wep_modes.get_dps(3,2)) ))

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "DPA (secondary): " ..
            game_str.add_commas( math.floor( game_wep_modes.get_dpa(3,2)) ))

        cur_y = cur_y - step_y
        cur_y = cur_y - step_y
        if not game_can_use.main(3) then
            ga_win_txt(wid, min_x,cur_y, "^xff0000YOU CANNOT USE THIS WEAPON BECAUSE YOU ")
            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xff0000HAVE NOT PICKED UP AN UPGRADE FOR IT")
        end
    end

    if win_num == 4 then
        ga_win_txt(wid, min_x,cur_y, "WEAPON #4 (Rocket)")

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "MAX AMMO: " ..
            game_str.add_commas( game_wep_modes.get_ammo_max(4) ) )

        cur_y = cur_y - step_y
        local fire_rate = 1.0 / game_wep_modes.get_fire_period(4,1)
        local mcolor = p.max_color(
            "xar.player.gun4.fire_period_level",
            game_wep_modes.get_fire_period_level_max(4))
        ga_win_txt(wid, min_x,cur_y, mcolor .. "FIRE RATE: " .. p.round(fire_rate,2) .. " per sec")

        --Mode 1 (Basic rockets)
        if game_wep_modes.get_equipped(4,1) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local damage = game_wep_modes.get_curved_direct_hit_from_player(4,1)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE DIRECT HIT (Basic): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            local raw_damage = game_wep_modes.get_curved_expl_damage(4,1)
            local damage = p.calc_dmg_from_player(raw_damage)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE SPLASH (Basic): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            local speed1 = game_wep_modes.get_vel(4,1)
            ga_win_txt(wid, min_x,cur_y, "VELOCITY (Basic): " .. speed1 .. " per sec")

            cur_y = cur_y - step_y
            local mcolor = p.max_color(
                "xar.player.gun4.radius_level",
                game_wep_modes.get_radius_level_max(4))
            ga_win_txt(wid, min_x,cur_y, mcolor .. "RADIUS (Basic): " ..
                game_wep_modes.get_radius(4,1) )
        end

        --Mode 2 (High velocity rockets)
        if game_wep_modes.get_equipped(4,2) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local damage = game_wep_modes.get_curved_direct_hit_from_player(4,2)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE DIRECT HIT (High Velocity): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            local speed1 = game_wep_modes.get_vel(4,2)
            ga_win_txt(wid, min_x,cur_y, "VELOCITY (High Velocity): " .. speed1 .. " per sec")
        end

        --Mode 3 (Big radius)
        if game_wep_modes.get_equipped(4,3) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local damage = game_wep_modes.get_curved_direct_hit_from_player(4,3)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE DIRECT HIT (Big Radius): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            local raw_damage = game_wep_modes.get_curved_expl_damage(4,3)
            local damage = p.calc_dmg_from_player(raw_damage)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE SPLASH (Big Radius): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            local speed1 = game_wep_modes.get_vel(4,3)
            ga_win_txt(wid, min_x,cur_y, "VELOCITY (Big Radius): " .. speed1 .. " per sec")

            cur_y = cur_y - step_y
            local mcolor = p.max_color(
                "xar.player.gun4.radius_level",
                game_wep_modes.get_radius_level_max(4))
            ga_win_txt(wid, min_x,cur_y, mcolor .. "RADIUS (Big Radius): " ..
                game_wep_modes.get_radius(4,3) )
        end

        --Mode 4 (Kinetic)
        if game_wep_modes.get_equipped(4,4) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local raw_damage = game_wep_modes.get_curved_damage(4,4)
            local damage = p.calc_dmg_from_player(raw_damage)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Kinetic Mode): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            local speed2 = game_wep_modes.get_vel(4,4)
            ga_win_txt(wid, min_x,cur_y, "VELOCITY (Kinetic Mode): " .. speed2 .. " per sec")
        end

        --Mode 5 (Kinetic)
        if game_wep_modes.get_equipped(4,5) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local raw_damage = game_wep_modes.get_curved_damage(4,5)
            local damage = p.calc_dmg_from_player(raw_damage)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Progressive Mode): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            local speed2 = game_wep_modes.get_vel(4,5)
            ga_win_txt(wid, min_x,cur_y, "VELOCITY (Progressive Mode): " .. speed2 .. " per sec")

            cur_y = cur_y - step_y
            cur_y = cur_y - step_y
        end

        cur_y = cur_y - step_y
        cur_y = cur_y - step_y

        if not game_can_use.main(4) then
            ga_win_txt(wid, min_x,cur_y, "^xff0000YOU CANNOT USE THIS WEAPON BECAUSE YOU ")
            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xff0000HAVE NOT PICKED UP AN UPGRADE FOR IT")
        end
    end

    if win_num == 5 then
        --THIS REALLY ONLY DESCRIBES THE PRIMARY FIRE!!!
        --SECONDARY SHOOTS MORE AMMO PER SECOND!!!

        ga_win_txt(wid, min_x,cur_y, "WEAPON #5 (Homing Rocket)")

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "MAX AMMO: " ..
            game_str.add_commas(game_wep_modes.get_ammo_max(5)) )

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "DPA: " ..
            game_str.add_commas( math.floor(game_wep_modes.get_dpa(5,1)) ) )

        cur_y = cur_y - step_y
        local fire_rate = 1.0 / game_wep_modes.get_fire_period(5,1)
        local mcolor = p.max_color(
            "xar.player.gun5.fire_period_level",
            game_wep_modes.get_fire_period_level_max(5))
        ga_win_txt(wid, min_x,cur_y, mcolor .. "FIRE RATE: " .. p.round(fire_rate,2) .. " per sec")

        cur_y = cur_y - step_y
        local mcolor = p.max_color(
            "xar.player.gun5.speed_level",
            game_wep_modes.get_vel_level_max(5))
        local speed = game_wep_modes.get_vel(5,1)
        ga_win_txt(wid, min_x,cur_y, mcolor .. "VELOCITY: " .. speed .. " per sec")

        --Primary only.
        cur_y = cur_y - step_y

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "DPS (primary): " ..
            game_str.add_commas( math.floor(game_wep_modes.get_dps(5,1)) ) )

        --Secondary only.
        cur_y = cur_y - step_y

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "DPS (secondary): " ..
            game_str.add_commas( math.floor(game_wep_modes.get_dps(5,2)) ) )

        cur_y = cur_y - step_y
        cur_y = cur_y - step_y
        if not game_can_use.main(5) then
            ga_win_txt(wid, min_x,cur_y, "^xff0000YOU CANNOT USE THIS WEAPON BECAUSE YOU ")
            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xff0000HAVE NOT PICKED UP AN UPGRADE FOR IT")
        end
    end

    if win_num == 6 then
        ga_win_txt(wid, min_x,cur_y, "WEAPON #6 (Minigun)")

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "MAX AMMO: " ..
            game_str.add_commas( game_wep_modes.get_ammo_max(6) ) )

        --Ok to print this.
        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "^xff00ff" .. "SPECIAL DAMAGE FACTOR: " ..
            ga_get_i("xar.player.gun6.num_level") + 1)

        --Primary only.
        cur_y = cur_y - step_y

        cur_y = cur_y - step_y
        local raw_damage = game_wep_modes.get_curved_damage(6,1)
        local damage = p.calc_dmg_from_player(raw_damage)
        ga_win_txt(wid, min_x,cur_y, "DAMAGE (primary): " ..
            game_str.add_commas(damage) )

        cur_y = cur_y - step_y
        local fire_rate = 1.0 / game_wep_modes.get_fire_period(6,1)
        local mcolor = p.max_color(
            "xar.player.gun6.fire_period_level",
            game_wep_modes.get_fire_period_level_max(6))
        ga_win_txt(wid, min_x,cur_y, mcolor ..
            "FIRE RATE (primary): " .. p.round(fire_rate,2) .. " per sec")

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "DPS (primary): " ..
            game_str.add_commas( math.floor(game_wep_modes.get_dps(6,1)) ) )

        --Secondary only.
        cur_y = cur_y - step_y

        cur_y = cur_y - step_y
        local raw_damage = game_wep_modes.get_poison_total_damage(6,2)
        local damage = p.calc_dmg_from_player(raw_damage)
        ga_win_txt(wid, min_x,cur_y, "DAMAGE (secondary): " ..
            game_str.add_commas(damage) )

        cur_y = cur_y - step_y
        local fire_rate = 1.0 / game_wep_modes.get_fire_period(6,2)
        local mcolor = p.max_color(
            "xar.player.gun6.fire_period_level",
            game_wep_modes.get_fire_period_level_max(6))
        ga_win_txt(wid, min_x,cur_y, mcolor ..
            "FIRE RATE (secondary): " .. p.round(fire_rate,2) .. " per sec")

        cur_y = cur_y - step_y
        local dps = game_wep_modes.get_dps(6,2)
        ga_win_txt(wid, min_x,cur_y, "DPS (secondary): " ..
            game_str.add_commas( math.floor(dps) ) )

        -- cur_y = cur_y - step_y
        -- ga_win_txt(wid, min_x,cur_y, "DPA (primary): " ..
        --     game_str.add_commas(damage) )

        cur_y = cur_y - step_y
        local speed = game_wep_modes.get_vel(6,2)
        local mcolor = p.max_color(
            "xar.player.gun6.speed_level",
            game_wep_modes.get_vel_level_max(6))
        ga_win_txt(wid, min_x,cur_y, mcolor ..
            "VELOCITY: (secondary): " .. speed .. " per sec")

        cur_y = cur_y - step_y
        cur_y = cur_y - step_y
        if not game_can_use.main(6) then
            ga_win_txt(wid, min_x,cur_y, "^xff0000YOU CANNOT USE THIS WEAPON BECAUSE YOU ")
            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xff0000HAVE NOT PICKED UP AN UPGRADE FOR IT")
        end
    end

    if win_num == 7 then
        ga_win_txt(wid, min_x,cur_y, "WEAPON #7 (Railgun)")

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "MAX AMMO: " ..
            game_str.add_commas( game_wep_modes.get_ammo_max(7) ) )

        cur_y = cur_y - step_y
        local fire_rate = 1.0 / game_wep_modes.get_fire_period(7,1)
        local mcolor = p.max_color(
            "xar.player.gun7.fire_period_level",
            game_wep_modes.get_fire_period_level_max(7))
        ga_win_txt(wid, min_x,cur_y, mcolor .. "FIRE RATE: " .. p.round(fire_rate, 2) .. " per sec")

        --Mode 1.
        if game_wep_modes.get_equipped(7,1) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local raw_damage = game_wep_modes.get_curved_damage(7,1)
            local damage = p.calc_dmg_from_player(raw_damage)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Classic Railgun): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Classic Railgun): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_dps(7,1)) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Classic Railgun): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_dpa(7,1))) )
        end

        --Mode 2.
        if game_wep_modes.get_equipped(7,2) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local raw_damage = game_wep_modes.get_curved_damage(7,2)
            local damage = p.calc_dmg_from_player(raw_damage)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Rapid Railgun): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Rapid Railgun): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_dps(7,2)) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Rapid Railgun): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_dpa(7,2))) )
        end

        --Mode 3.
        if game_wep_modes.get_equipped(7,3) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local raw_damage = game_wep_modes.get_curved_damage(7,3)
            local damage = p.calc_dmg_from_player(raw_damage)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Vampire Railgun): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Vampire Railgun): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_dps(7,3)) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Vampire Railgun): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_dpa(7,3)) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xffffff" .. "HEALTH BONUS (Vampire Railgun): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_health_bonus(7,3)) ) )
        end

        --Mode 4.
        if game_wep_modes.get_equipped(7,4) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local raw_damage = game_wep_modes.get_curved_damage(7,4)
            local damage = p.calc_dmg_from_player(raw_damage)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Super Vampire Railgun): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPS (Super Vampire Railgun): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_dps(7,4)) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DPA (Super Vampire Railgun): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_dpa(7,4)) ) )

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xffffff" .. "HEALTH BONUS (Super Vampire Railgun): " ..
                game_str.add_commas( math.floor(game_wep_modes.get_health_bonus(7,4)) ) )
        end

        cur_y = cur_y - step_y
        cur_y = cur_y - step_y
        if not game_can_use.main(7) then
            ga_win_txt(wid, min_x,cur_y, "^xff0000YOU CANNOT USE THIS WEAPON BECAUSE YOU ")
            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xff0000HAVE NOT PICKED UP AN UPGRADE FOR IT")
        end
    end

    if win_num == 8 then
        ga_win_txt(wid, min_x,cur_y, "WEAPON #8 (EMP)")

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "MAX AMMO: " ..
            game_str.add_commas(game_wep_modes.get_ammo_max(8)) )

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "RADIUS: " ..
            game_str.add_commas( game_wep_modes.get_radius(8,1) ) )

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "FREEZE TIME: " ..
            game_str.add_commas( game_wep_modes.get_freeze_length(8,1) ) .. " sec" )

        --Primary only.
        --Nothing to print.

        --Secondary only.
        cur_y = cur_y - step_y

        cur_y = cur_y - step_y
        local raw_damage = game_wep_modes.get_curved_damage(8,2)
        local damage = p.calc_dmg_from_player(raw_damage)
        ga_win_txt(wid, min_x,cur_y, "DAMAGE (secondary): " ..
            game_str.add_commas(damage) )

        cur_y = cur_y - step_y
        cur_y = cur_y - step_y
        if not game_can_use.main(8) then
            ga_win_txt(wid, min_x,cur_y, "^xff0000YOU CANNOT USE THIS WEAPON BECAUSE YOU ")
            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xff0000HAVE NOT PICKED UP AN UPGRADE FOR IT")
        end
    end

    if win_num == 9 then
        ga_win_txt(wid, min_x,cur_y, "WEAPON #9 (Nuke)")

        cur_y = cur_y - step_y
        ga_win_txt(wid, min_x,cur_y, "MAX AMMO: " ..
            game_str.add_commas( game_wep_modes.get_ammo_max(9) ) )

        --Mode 1.
        if game_wep_modes.get_equipped(9,1) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local raw_damage = game_wep_modes.get_curved_damage(9,1)
            local damage = p.calc_dmg_from_player(raw_damage);
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (High Damage): " ..
                game_str.add_commas( damage ) );

            cur_y = cur_y - step_y
            local speed = game_wep_modes.get_vel(9,1)
            ga_win_txt(wid, min_x,cur_y, "VELOCITY (High Damage): " ..
                game_str.add_commas(speed) .. " per sec");

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "RADIUS (High Damage): " ..
                game_str.add_commas( game_wep_modes.get_radius(9,1) ) )
        end

        --Mode 2.
        if game_wep_modes.get_equipped(9,2) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local raw_damage = game_wep_modes.get_curved_damage(9,2)
            local damage = p.calc_dmg_from_player(raw_damage)
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (High Velocity and Radius): " ..
                game_str.add_commas(damage) )

            cur_y = cur_y - step_y
            local speed = game_wep_modes.get_vel(9,2)
            ga_win_txt(wid, min_x,cur_y, "VELOCITY (High Velocity and Radius): " ..
                game_str.add_commas(speed) .. " per sec")

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "RADIUS (High Velocity and Radius): " ..
                game_str.add_commas(game_wep_modes.get_radius(9,2)) )
        end

        --Mode 3.
        if game_wep_modes.get_equipped(9,3) then
            cur_y = cur_y - step_y

            cur_y = cur_y - step_y
            local raw_damage = game_wep_modes.get_curved_damage(9,3)
            local damage = p.calc_dmg_from_player(raw_damage);
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (Nuclear Pulse Propulsion): " ..
                game_str.add_commas( damage ) );

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "RADIUS (Nuclear Pulse Propulsion): " ..
                game_str.add_commas( game_wep_modes.get_radius(9,3) ) )
        end

        cur_y = cur_y - step_y
        cur_y = cur_y - step_y
        if not game_can_use.main(9) then
            ga_win_txt(wid, min_x,cur_y, "^xff0000YOU CANNOT USE THIS WEAPON BECAUSE YOU ")
            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xff0000HAVE NOT PICKED UP AN UPGRADE FOR IT")
        end
    end

    if win_num == 10 then
        ga_win_txt(wid, min_x,cur_y, "WEAPON #10 (Dark Hole)")

        if game_can_use.main(0) then

            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "MAX AMMO: " ..
                game_str.add_commas( game_wep_modes.get_ammo_max(0) ) )

            cur_y = cur_y - step_y
            local speed = game_wep_modes.get_vel(0,1)
            ga_win_txt(wid, min_x,cur_y, "VELOCITY: " ..
                game_str.add_commas(speed) .. " per sec")

            cur_y = cur_y - step_y
            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "DAMAGE (direct hit): ")

            for i = 1,12 do
                cur_y = cur_y - step_y
                local raw_damage = game_wep_modes.get_curved_damage(0,1)
                local damage_mod = game_inv_exec.dark_hole_damage_factor(i)
                --The times 2 is because a direct hit also does AOE to the target monster.
                local damage = raw_damage * damage_mod
                local curved_damage = game_difficulty_curve.curve_player_damage(damage) * 10 * 2
                local allow_powerups = false
                local adjusted_damage = game_damage.calc_damage_from_player(curved_damage, allow_powerups)

                ga_win_txt(wid, min_x,cur_y, tostring(i) .. " CHARGE: " ..
                    game_str.add_commas( math.floor(adjusted_damage) ) )
            end
        else
            cur_y = cur_y - step_y
            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xff0000YOU CANNOT USE THIS WEAPON BECAUSE YOU ")
            cur_y = cur_y - step_y
            ga_win_txt(wid, min_x,cur_y, "^xff0000HAVE NOT PICKED UP AN UPGRADE FOR IT")
        end
    end

    ga_win_set_char_size(wid, 0.02, 0.04)
    ga_win_txt_center(wid, 0.06, "Go Back (ESC)")
end

function p.__process_input(wid)
    if ga_win_key_pressed(wid, "ESC") then
        ga_window_pop()
        return
    end

    if ga_win_key_pressed(wid, "F1") then
        --Opening the xar menu.
        ga_window_pop()
        ga_main_menu_push("main_menu")
        return
    end
    if ga_win_key_pressed(wid, "F2") then
        ga_window_pop()
        ga_window_push("win_stats2")
        return
    end
    --
    if ga_win_key_pressed(wid, "F4") then
        ga_window_pop()
        ga_window_push("win_stats4")
        return
    end
    if ga_win_key_pressed(wid, "F5") then
        ga_window_pop()
        ga_window_push("win_stats5")
        return
    end
    if ga_win_key_pressed(wid, "F6") then
        ga_window_pop()
        ga_window_push("win_stats6")
        return
    end
    if ga_win_key_pressed(wid, "F7") then
        ga_window_pop()
        ga_window_push("win_stats7")
        return
    end

    --Switching sub windows.
    ga_init_i("temp.xar.stats3.win_num", 1)
    num = ga_get_i("temp.xar.stats3.win_num")
    if ga_win_key_pressed(wid, "1") then num = 1 end
    if ga_win_key_pressed(wid, "2") then num = 2 end
    if ga_win_key_pressed(wid, "3") then num = 3 end
    if ga_win_key_pressed(wid, "4") then num = 4 end
    if ga_win_key_pressed(wid, "5") then num = 5 end
    if ga_win_key_pressed(wid, "6") then num = 6 end
    if ga_win_key_pressed(wid, "7") then num = 7 end
    if ga_win_key_pressed(wid, "8") then num = 8 end
    if ga_win_key_pressed(wid, "9") then num = 9 end
    if ga_win_key_pressed(wid, "0") then num = 10 end
    if ( ( ga_win_mouse_wheel_down(wid) or ga_win_key_pressed(wid, "LEFT")  ) and num > 1 ) then num = num - 1 end
    if ( ( ga_win_mouse_wheel_up(wid)   or ga_win_key_pressed(wid, "RIGHT") ) and num < 10 ) then num = num + 1 end
    ga_set_i("temp.xar.stats3.win_num", num)
end
