Changling evolution menu becomes cellular emporium

Now with TGUI! Wow!
This commit is contained in:
Jack Edge
2016-06-11 02:50:53 +01:00
parent eea7d5f93d
commit 9543fc891b
9 changed files with 147 additions and 319 deletions

View File

@@ -127,7 +127,7 @@
if(button_icon && button_icon_state)
// If set, use the custom icon that we set instead
// of the item appereance
// of the item appearence
..(current_button)
else if(target)
var/obj/item/I = target

View File

@@ -0,0 +1,81 @@
// cellular emporium
// The place where changelings go to buy their biological weaponry.
/datum/cellular_emporium
var/name = "cellular emporium"
var/datum/changeling/changeling
/datum/cellular_emporium/New(my_changeling)
changeling = my_changeling
/datum/cellular_emporium/Destroy()
changeling = null
. = ..()
/datum/cellular_emporium/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = always_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "cellular_emporium", name, 900, 480, master_ui, state)
ui.open()
/datum/cellular_emporium/ui_data(mob/user)
var/list/data = list()
var/can_readapt = changeling.canrespec
var/genetic_points_remaining = changeling.geneticpoints
var/absorbed_dna_count = changeling.absorbedcount
data["can_readapt"] = can_readapt
data["genetic_points_remaining"] = genetic_points_remaining
data["absorbed_dna_count"] = absorbed_dna_count
var/list/abilities = list()
for(var/path in subtypesof(/obj/effect/proc_holder/changeling))
var/obj/effect/proc_holder/changeling/ability = new path()
if(ability.dna_cost <= 0)
continue
var/list/AL = list()
AL["name"] = ability.name
AL["desc"] = ability.desc
AL["helptext"] = ability.helptext
AL["owned"] = changeling.has_sting(ability)
AL["required_absorptions"] = ability.req_dna
AL["dna_cost"] = ability.dna_cost
AL["can_purchase"] = ((ability.req_dna <= absorbed_dna_count) && (ability.dna_cost <= genetic_points_remaining))
abilities += list(AL)
data["abilities"] = abilities
return data
/datum/cellular_emporium/ui_act(action, params)
if(..())
return
switch(action)
if("readapt")
if(changeling.canrespec)
changeling.lingRespec(usr)
if("evolve")
var/sting_name = params["name"]
changeling.purchasePower(usr, sting_name)
/datum/action/innate/cellular_emporium
name = "Cellular Emporium"
button_icon_state = "cellular_emporium"
background_icon_state = "bg_alien"
var/datum/cellular_emporium/cellular_emporium
/datum/action/innate/cellular_emporium/New(our_target)
. = ..()
button.name = name
if(istype(our_target, /datum/cellular_emporium))
cellular_emporium = our_target
else
throw EXCEPTION("cellular_emporium action created with non emporium")
/datum/action/innate/cellular_emporium/Activate()
cellular_emporium.ui_interact(owner)

View File

@@ -99,7 +99,6 @@ var/list/slot2type = list("head" = /obj/item/clothing/head/changeling, "wear_mas
greet_changeling(changeling)
ticker.mode.update_changeling_icons_added(changeling)
..()
return
/datum/game_mode/changeling/make_antag_chance(mob/living/carbon/human/character) //Assigns changeling to latejoiners
var/changelingcap = min( round(joined_player_list.len/(config.changeling_scaling_coeff*2))+2, round(joined_player_list.len/config.changeling_scaling_coeff) )
@@ -298,6 +297,8 @@ var/list/slot2type = list("head" = /obj/item/clothing/head/changeling, "wear_mas
var/changeling_speak = 0
var/datum/dna/chosen_dna
var/obj/effect/proc_holder/changeling/sting/chosen_sting
var/datum/cellular_emporium/cellular_emporium
var/datum/action/innate/cellular_emporium/emporium_action
/datum/changeling/New(var/gender=FEMALE)
..()
@@ -313,9 +314,17 @@ var/list/slot2type = list("head" = /obj/item/clothing/head/changeling, "wear_mas
else
changelingID = "[honorific] [rand(1,999)]"
cellular_emporium = new(src)
emporium_action = new(cellular_emporium)
/datum/changeling/Destroy()
qdel(cellular_emporium)
cellular_emporium = null
. = ..()
/datum/changeling/proc/regenerate(var/mob/living/carbon/the_ling)
if(istype(the_ling))
emporium_action.Grant(the_ling)
if(the_ling.stat == DEAD)
chem_charges = min(max(0, chem_charges + chem_recharge_rate - chem_recharge_slowdown), (chem_storage*0.5))
geneticdamage = max(LING_DEAD_GENETICDAMAGE_HEAL_CAP,geneticdamage-1)
@@ -486,7 +495,7 @@ var/list/slot2type = list("head" = /obj/item/clothing/head/changeling, "wear_mas
/datum/changelingprofile/Destroy()
qdel(dna)
return ..()
. = ..()
/datum/changelingprofile/proc/copy_profile(datum/changelingprofile/newprofile)
newprofile.name = name

View File

@@ -1,309 +1,8 @@
var/list/sting_paths
// totally stolen from the new player panel. YAYY
/obj/effect/proc_holder/changeling/evolution_menu
name = "-Evolution Menu-" //Dashes are so it's listed before all the other abilities.
desc = "Choose our method of subjugation."
dna_cost = 0
/obj/effect/proc_holder/changeling/evolution_menu/Click()
if(!usr || !usr.mind || !usr.mind.changeling)
return
var/datum/changeling/changeling = usr.mind.changeling
if(!sting_paths)
sting_paths = init_paths(/obj/effect/proc_holder/changeling)
var/dat = create_menu(changeling)
usr << browse(dat, "window=powers;size=600x700")//900x480
/obj/effect/proc_holder/changeling/evolution_menu/proc/create_menu(datum/changeling/changeling)
var/dat
dat +="<html><head><title>Changling Evolution Menu</title></head>"
//javascript, the part that does most of the work~
dat += {"
<head>
<script type='text/javascript'>
var locked_tabs = new Array();
function updateSearch(){
var filter_text = document.getElementById('filter');
var filter = filter_text.value.toLowerCase();
if(complete_list != null && complete_list != ""){
var mtbl = document.getElementById("maintable_data_archive");
mtbl.innerHTML = complete_list;
}
if(filter.value == ""){
return;
}else{
var maintable_data = document.getElementById('maintable_data');
var ltr = maintable_data.getElementsByTagName("tr");
for ( var i = 0; i < ltr.length; ++i )
{
try{
var tr = ltr\[i\];
if(tr.getAttribute("id").indexOf("data") != 0){
continue;
}
var ltd = tr.getElementsByTagName("td");
var td = ltd\[0\];
var lsearch = td.getElementsByTagName("b");
var search = lsearch\[0\];
//var inner_span = li.getElementsByTagName("span")\[1\] //Should only ever contain one element.
//document.write("<p>"+search.innerText+"<br>"+filter+"<br>"+search.innerText.indexOf(filter))
if ( search.innerText.toLowerCase().indexOf(filter) == -1 )
{
//document.write("a");
//ltr.removeChild(tr);
td.innerHTML = "";
i--;
}
}catch(err) { }
}
}
var count = 0;
var index = -1;
var debug = document.getElementById("debug");
locked_tabs = new Array();
}
function expand(id,name,desc,helptext,power,ownsthis){
clearAll();
var span = document.getElementById(id);
body = "<table><tr><td>";
body += "</td><td align='center'>";
body += "<font size='2'><b>"+desc+"</b></font> <BR>"
body += "<font size='2'><span class='danger'>"+helptext+"</span></font> <BR>"
if(!ownsthis)
{
body += "<a href='?src=\ref[src];P="+power+"'>Evolve</a>"
}
body += "</td><td align='center'>";
body += "</td></tr></table>";
span.innerHTML = body
}
function clearAll(){
var spans = document.getElementsByTagName('span');
for(var i = 0; i < spans.length; i++){
var span = spans\[i\];
var id = span.getAttribute("id");
if(!(id.indexOf("item")==0))
continue;
var pass = 1;
for(var j = 0; j < locked_tabs.length; j++){
if(locked_tabs\[j\]==id){
pass = 0;
break;
}
}
if(pass != 1)
continue;
span.innerHTML = "";
}
}
function addToLocked(id,link_id,notice_span_id){
var link = document.getElementById(link_id);
var decision = link.getAttribute("name");
if(decision == "1"){
link.setAttribute("name","2");
}else{
link.setAttribute("name","1");
removeFromLocked(id,link_id,notice_span_id);
return;
}
var pass = 1;
for(var j = 0; j < locked_tabs.length; j++){
if(locked_tabs\[j\]==id){
pass = 0;
break;
}
}
if(!pass)
return;
locked_tabs.push(id);
var notice_span = document.getElementById(notice_span_id);
notice_span.innerHTML = "<span class='danger'>Locked</span> ";
//link.setAttribute("onClick","attempt('"+id+"','"+link_id+"','"+notice_span_id+"');");
//document.write("removeFromLocked('"+id+"','"+link_id+"','"+notice_span_id+"')");
//document.write("aa - "+link.getAttribute("onClick"));
}
function attempt(ab){
return ab;
}
function removeFromLocked(id,link_id,notice_span_id){
//document.write("a");
var index = 0;
var pass = 0;
for(var j = 0; j < locked_tabs.length; j++){
if(locked_tabs\[j\]==id){
pass = 1;
index = j;
break;
}
}
if(!pass)
return;
locked_tabs\[index\] = "";
var notice_span = document.getElementById(notice_span_id);
notice_span.innerHTML = "";
//var link = document.getElementById(link_id);
//link.setAttribute("onClick","addToLocked('"+id+"','"+link_id+"','"+notice_span_id+"')");
}
function selectTextField(){
var filter_text = document.getElementById('filter');
filter_text.focus();
filter_text.select();
}
</script>
</head>
"}
//body tag start + onload and onkeypress (onkeyup) javascript event calls
dat += "<body onload='selectTextField(); updateSearch();' onkeyup='updateSearch();'>"
//title + search bar
dat += {"
<table width='560' align='center' cellspacing='0' cellpadding='5' id='maintable'>
<tr id='title_tr'>
<td align='center'>
<font size='5'><b>Changeling Evolution Menu</b></font><br>
Hover over a power to see more information<br>
Current ability choices remaining: [changeling.geneticpoints]<br>
By rendering a lifeform to a husk, we gain enough power to alter and adapt our evolutions.<br>
(<a href='?src=\ref[src];readapt=1'>Readapt</a>)<br>
<p>
</td>
</tr>
<tr id='search_tr'>
<td align='center'>
<b>Search:</b> <input type='text' id='filter' value='' style='width:300px;'>
</td>
</tr>
</table>
"}
//player table header
dat += {"
<span id='maintable_data_archive'>
<table width='560' align='center' cellspacing='0' cellpadding='5' id='maintable_data'>"}
var/i = 1
for(var/path in sting_paths)
var/obj/effect/proc_holder/changeling/P = new path()
if(P.dna_cost <= 0) //Let's skip the crap we start with. Keeps the evolution menu uncluttered.
continue
var/ownsthis = changeling.has_sting(P)
var/color
if(ownsthis)
if(i%2 == 0)
color = "#d8ebd8"
else
color = "#c3dec3"
else
if(i%2 == 0)
color = "#f2f2f2"
else
color = "#e6e6e6"
dat += {"
<tr id='data[i]' name='[i]' onClick="addToLocked('item[i]','data[i]','notice_span[i]')">
<td align='center' bgcolor='[color]'>
<span id='notice_span[i]'></span>
<a id='link[i]'
onmouseover='expand("item[i]","[P.name]","[P.desc]","[P.helptext]","[P]",[ownsthis])'
>
<b id='search[i]'>Evolve [P][ownsthis ? " - Purchased" : (P.req_dna>changeling.absorbedcount ? " - Requires [P.req_dna] absorptions" : " - Cost: [P.dna_cost]")]</b>
</a>
<br><span id='item[i]'></span>
</td>
</tr>
"}
i++
//player table ending
dat += {"
</table>
</span>
<script type='text/javascript'>
var maintable = document.getElementById("maintable_data_archive");
var complete_list = maintable.innerHTML;
</script>
</body></html>
"}
return dat
/obj/effect/proc_holder/changeling/evolution_menu/Topic(href, href_list)
..()
if(!(iscarbon(usr) && usr.mind && usr.mind.changeling))
return
if(href_list["P"])
usr.mind.changeling.purchasePower(usr, href_list["P"])
else if(href_list["readapt"])
usr.mind.changeling.lingRespec(usr)
var/dat = create_menu(usr.mind.changeling)
usr << browse(dat, "window=powers;size=600x700")
/////
/datum/changeling/proc/purchasePower(mob/living/carbon/user, sting_name)
var/obj/effect/proc_holder/changeling/thepower = null
if(!sting_paths)
sting_paths = init_paths(/obj/effect/proc_holder/changeling)
for(var/path in sting_paths)
for(var/path in subtypesof(/obj/effect/proc_holder/changeling))
var/obj/effect/proc_holder/changeling/S = new path()
if(S.name == sting_name)
thepower = S
@@ -358,12 +57,10 @@ var/list/sting_paths
return
if(!mind.changeling)
mind.changeling = new /datum/changeling(gender)
if(!sting_paths)
sting_paths = init_paths(/obj/effect/proc_holder/changeling)
if(mind.changeling.purchasedpowers)
remove_changeling_powers(1)
// purchase free powers.
for(var/path in sting_paths)
for(var/path in subtypesof(/obj/effect/proc_holder/changeling))
var/obj/effect/proc_holder/changeling/S = new path()
if(!S.dna_cost)
if(!mind.changeling.has_sting(S))

View File

@@ -0,0 +1,11 @@
/**
* tgui state: always_state
*
* Always grants the user UI_INTERACTIVE. Period.
**/
/var/global/datum/ui_state/always_state/always_state = new()
/datum/ui_state/always_state/can_use_topic(src_object, mob/user)
return UI_INTERACTIVE

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 80 KiB

View File

@@ -283,6 +283,7 @@
#include "code\game\gamemodes\blob\blobs\node.dm"
#include "code\game\gamemodes\blob\blobs\resource.dm"
#include "code\game\gamemodes\blob\blobs\shield.dm"
#include "code\game\gamemodes\changeling\cellular_emporium.dm"
#include "code\game\gamemodes\changeling\changeling.dm"
#include "code\game\gamemodes\changeling\changeling_power.dm"
#include "code\game\gamemodes\changeling\evolution_menu.dm"
@@ -1780,6 +1781,7 @@
#include "code\modules\tgui\subsystem.dm"
#include "code\modules\tgui\tgui.dm"
#include "code\modules\tgui\states\admin.dm"
#include "code\modules\tgui\states\always.dm"
#include "code\modules\tgui\states\conscious.dm"
#include "code\modules\tgui\states\contained.dm"
#include "code\modules\tgui\states\deep_inventory.dm"

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,28 @@
<ui-display title="Cellular Emporium" button>
<ui-button icon='refresh' state='{{data.can_readapt ? null : "disabled"}}'
action='readapt'>Readapt</ui-button>
<ui-section label='Genetic Points Remaining' right>
{{data.genetic_points_remaining}}
</ui-section>
</ui-display>
<ui-display>
{{#each data.abilities}}
<ui-section label='{{name}}' candystripe right>
<span>{{desc}}</span>
<span>{{helptext}}</span>
<span>Cost: {{dna_cost}}</span>
{{#if required_absorbtions}}
<span>Required Absorbtions: {{required_absorbtions}}
{{/if}}
<ui-button state='{{owned ? "selected" : can_purchase ? null : "disabled"}}'
action='evolve' params='{"name": "{{name}}"}'>
{{owned ? "Evolved" : "Evolve"}}
</ui-button>
</ui-section>
{{/each}}
{{^data.abilities}}
<span class='warning'>No abilities availible.</span>
{{/data.abilities}}
</ui-display>