khanat-opennel-code/code/ryzom/client/data/gamedev/interfaces_v3/out_v2_appear.lua

421 lines
14 KiB
Lua
Raw Normal View History

2016-01-24 16:08:32 +00:00
-- In this file we define functions that serves outgame character creation
------------------------------------------------------------------------------------------------------------
-- create the game namespace without reseting if already created in an other file.
if (outgame==nil) then
outgame= {};
end
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
------------------------------------------------------------------------------------------------------------
-- Name generator.
--nb noms:
2016-03-05 10:51:08 +00:00
-- matis: male 621 - female 621 - FirstName 621
-- fyros: given name 14269, FirstName 841
-- zorai: given name one 318, given name two 644, FirstName 1287
-- tryker: given name 4500, FirstName 4335
2016-02-20 18:57:43 +00:00
2016-03-05 10:51:08 +00:00
-- Fyros
function outgame:getFyrosLastName()
local nbFyrosLastNames = 0;
for _ in pairs(fyrosLastNames) do nbFyrosLastNames = nbFyrosLastNames + 1 end
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
return fyrosLastNames[math.random(nbFyrosLastNames)]
end
function outgame:getFyrosFirstName()
local nbFyrosFirstNames = 0;
for _ in pairs(fyrosFirstNames) do nbFyrosFirstNames = nbFyrosFirstNames + 1 end
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
return fyrosFirstNames[math.random(nbFyrosFirstNames)]
2016-02-20 18:57:43 +00:00
end
2016-03-05 10:51:08 +00:00
-- Matis
function outgame:getMatisLastName(sex)
2016-02-20 18:57:43 +00:00
local dbNameSex = getDbProp("UI:TEMP:NAME_SEX");
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
if sex ~= nil then
2016-03-05 10:51:08 +00:00
dbNameSex = sex;
2016-02-20 18:57:43 +00:00
end
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
local LastName = ""
2016-02-20 19:44:23 +00:00
if tonumber( dbNameSex )== 1 then
2016-03-05 10:51:08 +00:00
local nbMatisMaleLastNames = 0;
for _ in pairs(matisMaleLastNames) do nbMatisMaleLastNames = nbMatisMaleLastNames + 1 end
LastName = matisMaleLastNames[math.random(nbMatisMaleLastNames)];
2016-02-20 18:57:43 +00:00
else
2016-03-05 10:51:08 +00:00
local nbMatisFemaleLastNames = 0;
for _ in pairs(matisFemaleLastNames) do nbMatisFemaleLastNames = nbMatisFemaleLastNames + 1 end
LastName = matisFemaleLastNames[math.random(nbMatisFemaleLastNames)];
2016-02-20 18:57:43 +00:00
end
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
return LastName;
2016-02-20 18:57:43 +00:00
end
2016-03-05 10:51:08 +00:00
function outgame:getMatisFirstName()
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
local nbMatisFirstNames = 0;
for _ in pairs(matisFirstNames) do nbMatisFirstNames = nbMatisFirstNames + 1 end
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
return matisFirstNames[math.random(nbMatisFirstNames)]
2016-02-20 18:57:43 +00:00
end
2016-03-05 10:51:08 +00:00
-- Tryker
function outgame:getTrykerLastName()
local nbTrykerLastNames = 0;
for _ in pairs(trykerLastNames) do nbTrykerLastNames = nbTrykerLastNames + 1 end
2016-02-20 18:57:43 +00:00
2016-03-05 10:51:08 +00:00
return trykerLastNames[math.random(nbTrykerLastNames)]
end
function outgame:getTrykerFirstName()
local nbTrykerFirstNames = 0;
for _ in pairs(trykerFirstNames) do nbTrykerFirstNames = nbTrykerFirstNames + 1 end
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
return trykerFirstNames[math.random(nbTrykerFirstNames)]
end
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
-- Zora<72>
function outgame:getZoraiLastName()
local nbLastNamesOne = 0;
for _ in pairs(zoraiLastNamesOne) do nbLastNamesOne = nbLastNamesOne + 1 end
local lastNameOne = zoraiLastNamesOne[math.random(nbLastNamesOne)];
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
local nbLastNamesTwo = 0;
for _ in pairs(zoraiLastNamesTwo) do nbLastNamesTwo = nbLastNamesTwo + 1 end
local lastNameTwo = zoraiLastNamesTwo[math.random(nbLastNamesTwo)];
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
return lastNameOne .. "-" .. lastNameTwo
end
function outgame:getZoraiFirstName()
local nbFirstNames = 0;
for _ in pairs(zoraiFirstNames) do nbFirstNames = nbFirstNames + 1 end
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
return zoraiFirstNames[math.random(nbFirstNames)]
2016-02-20 18:57:43 +00:00
end
function outgame:procGenerateName()
local uiNameFull = getUI("ui:outgame:appear_name:name_full");
local uiGenText = getUI("ui:outgame:appear_name:eb");
local dbNameRace = getDbProp("UI:TEMP:NAME_RACE");
local dbNameSubRace = getDbProp("UI:TEMP:NAME_SUB_RACE");
local dbNameSubRace2 = getDbProp("UI:TEMP:NAME_SUB_RACE2");
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
local nameResult = "";
local fullnameResult = "";
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
-- Look at outgame:procUpdateNameRaceLabel() for the "race" list.
-- fy ma try zo -->
2016-03-05 10:51:08 +00:00
local lastName = "test"
local firstName = "test2"
2016-02-20 18:57:43 +00:00
if tonumber( dbNameRace ) == 1 then
-- Fyros
2016-03-05 10:51:08 +00:00
lastName = self:getFyrosLastName()
firstName = self:getFyrosFirstName()
fullnameResult = lastName .. " " .. firstName
nameResult = lastName
2016-02-20 18:57:43 +00:00
elseif tonumber( dbNameRace ) == 2 then
-- Matis
2016-03-05 10:51:08 +00:00
lastName = self:getMatisLastName()
firstName = self:getMatisFirstName()
fullnameResult = lastName .. " " .. firstName
nameResult = lastName
2016-02-20 18:57:43 +00:00
elseif tonumber( dbNameRace ) == 3 then
-- Tryker
2016-03-05 10:51:08 +00:00
lastName = self:getTrykerLastName()
firstName = self:getTrykerFirstName()
fullnameResult = firstName .. " " .. lastName
nameResult = lastName
2016-02-20 18:57:43 +00:00
elseif tonumber( dbNameRace ) == 4 then
-- Zorai
2016-03-05 10:51:08 +00:00
lastName = self:getZoraiLastName()
firstName = self:getZoraiFirstName()
fullnameResult = firstName .. " " .. lastName
nameResult = lastName
2016-02-20 18:57:43 +00:00
elseif tonumber( dbNameRace ) == 5 then
-- Maraudeurs
2016-03-05 10:51:08 +00:00
-- lastName
2016-02-20 18:57:43 +00:00
if tonumber(dbNameSubRace) == 1 then
-- Fyros
2016-03-05 10:51:08 +00:00
lastName = self:getFyrosLastName()
2016-02-20 18:57:43 +00:00
elseif tonumber( dbNameSubRace ) == 2 then
-- Matis F
2016-03-05 10:51:08 +00:00
lastName = self:getMatisLastName(2)
2016-02-20 18:57:43 +00:00
elseif tonumber( dbNameSubRace ) == 3 then
-- Matis M
2016-03-05 10:51:08 +00:00
lastName = self:getMatisLastName(1)
2016-02-20 18:57:43 +00:00
elseif tonumber( dbNameSubRace ) == 4 then
-- Tryker
2016-03-05 10:51:08 +00:00
lastName = self:getTrykerLastName()
2016-02-20 18:57:43 +00:00
elseif tonumber( dbNameSubRace ) == 5 then
-- Zorai
2016-03-05 10:51:08 +00:00
lastName = self:getZoraiLastName()
2016-02-20 18:57:43 +00:00
end
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
-- firstName
2016-02-20 18:57:43 +00:00
if tonumber(dbNameSubRace2) == 1 then
-- Fyros
2016-03-05 10:51:08 +00:00
firstName = self:getFyrosFirstName()
2016-02-20 18:57:43 +00:00
elseif tonumber( dbNameSubRace2 ) == 2 then
2016-03-05 10:51:08 +00:00
-- Matis
firstName = self:getMatisFirstName()
firstName = self:getMatisFirstName()
2016-02-20 18:57:43 +00:00
elseif tonumber( dbNameSubRace2 ) == 3 then
-- Tryker
2016-03-05 10:51:08 +00:00
firstName = self:getTrykerFirstName()
elseif tonumber( dbNameSubRace2 ) == 4 then
2016-02-20 18:57:43 +00:00
-- Zorai
2016-03-05 10:51:08 +00:00
firstName = self:getZoraiFirstName()
2016-02-20 18:57:43 +00:00
end
2016-02-20 19:44:23 +00:00
2016-03-05 10:51:08 +00:00
fullnameResult = lastName .. " " .. firstName
nameResult = lastName
2016-02-20 18:57:43 +00:00
end
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
uiNameFull.hardtext = fullnameResult;
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
nameResult = string.gsub(nameResult, "'", "");
nameResult = string.gsub(nameResult, " ", "");
nameResult = string.gsub(nameResult, "-", "");
nameResult = string.lower( nameResult );
nameResult = nameResult:gsub("^%l", string.upper);
uiGenText.input_string = nameResult;
end
-- Name sex slider update.
function outgame:procUpdateNameSexLabel()
local nameSexType = { "uiCP_Sex_Male", "uiCP_Sex_Female" }
local uiNameSexText = getUI("ui:outgame:appear_name:name_sex_slider:name_sex");
local uiNameSex = getDbProp("UI:TEMP:NAME_SEX");
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
tempstr = tostring(i18n.get(nameSexType[tonumber(uiNameSex)]));
tempstr = string.lower( tempstr );
tempstr = (tempstr:gsub("^%l", string.upper));
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
uiNameSexText.hardtext= tempstr;
end
-- Name race slider update.
function outgame:procUpdateNameRaceLabel()
local nameRaceType = { "Fyros", "Matis", "Tryker", "Zora<EFBFBD>", "uiCP_Maraudeur" }
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
local uiNameRaceText = getUI("ui:outgame:appear_name:name_race_slider:name_race");
local dbNameRace = getDbProp("UI:TEMP:NAME_RACE");
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
local uiNameSexSlider = getUI("ui:outgame:appear_name:name_sex_slider");
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
local uiNameSubRaceSlider = getUI("ui:outgame:appear_name:name_sub_race_slider");
local uiNameSubRace2Slider = getUI("ui:outgame:appear_name:name_sub_race2_slider");
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
local uiNameGenerate = getUI("ui:outgame:appear_name:generate");
-- Show/Hide sex slider
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
uiNameGenerate.y = "-50"
if tonumber(dbNameRace) == 2 then
uiNameSexSlider.active = true;
uiNameGenerate.y = "-65"
else
uiNameSexSlider.active = false;
end
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
-- Show/Hide sub race slider
if tonumber(dbNameRace) == 5 then
uiNameSubRaceSlider.active = true;
uiNameSubRace2Slider.active = true;
uiNameGenerate.y = "-105"
else
uiNameSubRaceSlider.active = false;
uiNameSubRace2Slider.active = false;
end
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
uiNameRaceText.hardtext= tostring(nameRaceType[tonumber(dbNameRace)]);
end
local matisF = "Matis " .. (string.lower(tostring(i18n.get("uiCP_Sex_Female")) )):gsub("^%l", string.upper);
local matisM = "Matis " .. (string.lower(tostring(i18n.get("uiCP_Sex_Male")) )):gsub("^%l", string.upper);
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
function outgame:procUpdateNameSubRaceLabel()
local nameSubRaceType = { "Fyros", matisF, matisM, "Tryker", "Zora<EFBFBD>" }
local uiNameSubRaceText = getUI("ui:outgame:appear_name:name_sub_race_slider:name_race");
local dbNameSubRace = getDbProp("UI:TEMP:NAME_SUB_RACE");
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
uiNameSubRaceText.hardtext= tostring(nameSubRaceType[tonumber(dbNameSubRace)]);
end
function outgame:procUpdateNameSubRace2Label()
2016-03-05 10:51:08 +00:00
local nameSubRace2Type = { "Fyros", "Matis", "Tryker", "Zora<EFBFBD>" }
2016-02-20 18:57:43 +00:00
local uiNameSubRace2Text = getUI("ui:outgame:appear_name:name_sub_race2_slider:name_race");
local dbNameSubRace2 = getDbProp("UI:TEMP:NAME_SUB_RACE2");
2016-02-20 19:44:23 +00:00
2016-02-20 18:57:43 +00:00
uiNameSubRace2Text.hardtext= tostring(nameSubRace2Type[tonumber(dbNameSubRace2)]);
end
2016-01-24 16:08:32 +00:00
------------------------------------------------------------------------------------------------------------
-- called to construct icons
function outgame:activePackElement(id, icon)
local uiDesc = getUI("ui:outgame:appear:job_options:options:desc");
uiDesc['ico' .. tostring(id)].active= true;
uiDesc['ico' .. tostring(id)].texture= icon;
uiDesc['ico' .. tostring(id) .. 'txt'].active= true;
end
------------------------------------------------------------------------------------------------------------
-- called to construct pack text
function outgame:setPackJobText(id, spec)
-- Set Pack content
local uiPackText = getUI("ui:outgame:appear:job_options:options:desc:pack_" .. id);
uiPackText.hardtext= "uiCP_Job_" .. id .. tostring(spec);
-- Set specialization text
local uiResText = getUI("ui:outgame:appear:job_options:options:result:res");
if(spec==2) then
uiResText.hardtext= "uiCP_Res_" .. id;
end
end
------------------------------------------------------------------------------------------------------------
-- called to construct pack
function outgame:buildActionPack()
local uiDesc = getUI("ui:outgame:appear:job_options:options:desc");
if (uiDesc==nil) then
return;
end
-- Reset All
for i = 1,20 do
uiDesc['ico' .. tostring(i)].active= false;
uiDesc['ico' .. tostring(i) .. 'txt'].active= false;
end
-- Build Default Combat
self:activePackElement(1, 'f1.tga'); -- Dagger
self:activePackElement(2, 'f2.tga'); -- Accurate Attack
2016-02-20 19:44:23 +00:00
2016-01-24 16:08:32 +00:00
-- Build Default Magic
self:activePackElement(6, 'm2.tga'); -- Gloves
self:activePackElement(7, 'm1.tga'); -- Acid
2016-02-20 19:44:23 +00:00
2016-01-24 16:08:32 +00:00
-- Build Default Forage
self:activePackElement(11, 'g1.tga'); -- Forage Tool
self:activePackElement(12, 'g2.tga'); -- Basic Extract
2016-02-20 19:44:23 +00:00
2016-01-24 16:08:32 +00:00
-- Build Default Craft
self:activePackElement(16, 'c2.tga'); -- Craft Tool
self:activePackElement(17, 'c1.tga'); -- 50 raw mat
self:activePackElement(18, 'c3.tga'); -- Craft Root
self:activePackElement(19, 'c4.tga'); -- Boots Plan
-- Build Option
if (getDbProp('UI:TEMP:JOB_FIGHT') == 2) then
self:activePackElement(3, 'f3.tga'); -- Increase damage
elseif (getDbProp('UI:TEMP:JOB_MAGIC') == 2) then
self:activePackElement(8, 'm5.tga'); -- Fear
elseif (getDbProp('UI:TEMP:JOB_FORAGE') == 2) then
self:activePackElement(13, 'g3.tga'); -- Basic Prospection
elseif (getDbProp('UI:TEMP:JOB_CRAFT') == 2) then
self:activePackElement(20, 'c6.tga'); -- Gloves Plan
self:activePackElement(17, 'c5.tga'); -- Replace 17, with 100x RawMat
end
-- Reset Text
self:setPackJobText('F', 1);
self:setPackJobText('M', 1);
self:setPackJobText('G', 1);
self:setPackJobText('C', 1);
2016-02-20 19:44:23 +00:00
-- Set correct text for specalized version
2016-01-24 16:08:32 +00:00
if (getDbProp('UI:TEMP:JOB_FIGHT') == 2) then
self:setPackJobText('F', 2);
elseif (getDbProp('UI:TEMP:JOB_MAGIC') == 2) then
self:setPackJobText('M', 2);
elseif (getDbProp('UI:TEMP:JOB_FORAGE') == 2) then
self:setPackJobText('G', 2);
elseif (getDbProp('UI:TEMP:JOB_CRAFT') == 2) then
self:setPackJobText('C', 2);
end
2016-02-20 19:44:23 +00:00
2016-01-24 16:08:32 +00:00
end
------------------------------------------------------------------------------------------------------------
-------------------
-- BG DOWNLOADER --
-------------------
--function outgame:getProgressGroup()
-- --debugInfo("*** 1 ***")
-- local grp = getUI("ui:outgame:charsel:bgd_progress")
-- --debugInfo(tostring(grp))
-- return grp
--end
--
--function outgame:setProgressText(ucstr, color, progress, ellipsis)
-- --debugInfo("*** 2 ***")
-- local text = self:getProgressGroup():find("text")
-- local ellipsisTxt = self:getProgressGroup():find("ellipsis")
-- text.color = color
-- text.uc_hardtext = ucstr
-- if ellipsis then
-- ellipsisTxt.hardtext = ellipsis
-- else
-- ellipsisTxt.hardtext = ""
-- end
-- ellipsisTxt.color = color
-- local progressCtrl = self:getProgressGroup():find("progress")
-- progressCtrl.range = 100
-- progressCtrl.value = progress * 100
-- progressCtrl.active = true
--end
--
--
--local progress progressSymbol = { ".", "..", "..." }
--
---- set patching progression (from 0 to 1)
--function outgame:setPatchProgress(progress)
-- --debugInfo("*** 3 ***")
-- local progressPercentText = string.format("%d%%", 100 * progress)
2016-02-20 19:44:23 +00:00
-- local progressPostfix = math.fmod(os.time(), 3)
-- --debugInfo("Patch in progress : " .. tostring(progress))
2016-01-24 16:08:32 +00:00
-- local progressDate = nltime.getLocalTime() / 500
-- local colValue = math.floor(230 + 24 * math.sin(progressDate))
-- local color = string.format("%d %d %d %d", colValue, colValue, colValue, 255)
-- self:setProgressText(concatUCString(i18n.get("uiBGD_Progress"), ucstring(progressPercentText)), color, progress, progressSymbol[progressPostfix + 1])
--end
--
--function outgame:setPatchSuccess()
-- --debugInfo("*** 4 ***")
-- --debugInfo("Patch up to date")
-- self:setProgressText(i18n.get("uiBGD_PatchUpToDate"), "0 255 0 255", 1)
--end
--
--
--function outgame:setPatchError()
-- --debugInfo("*** 5 ***")
2016-02-20 19:44:23 +00:00
-- --debugInfo("Patch error")
2016-01-24 16:08:32 +00:00
-- self:setProgressText(i18n.get("uiBGD_PatchError"), "255 0 0 255", 0)
--end
--
--function outgame:setNoPatch()
-- --self:getProgressGroup().active = false
--end
------------------------------------------------------------------------------------------------------------
----------------
--LAUNCH GAME --
----------------
function outgame:launchGame()
if not isPlayerSlotNewbieLand(getPlayerSelectedSlot()) then
if not isFullyPatched() then
2016-02-20 19:44:23 +00:00
messageBoxWithHelp(i18n.get("uiBGD_MainlandCharFullPatchNeeded"), "ui:outgame")
2016-01-24 16:08:32 +00:00
return
end
2016-02-20 19:44:23 +00:00
end
2016-01-24 16:08:32 +00:00
runAH(getUICaller(), "proc", "proc_charsel_play")
end