Skip to content

Commit

Permalink
nucleus in editor, locked organelle, gui change Revolutionary-Games#677
Browse files Browse the repository at this point in the history
Revolutionary-Games#678 Revolutionary-Games#679 (Revolutionary-Games#709)

* nucleus in editor, locked organelle, gui change

* fix function editor

* clang format fix

* fix space at line 196

* fix function onSelectNewOrganelle

from common.isEngine to common.isInEngine

* span space

* second span space

* space in microbe editor

* restore GUI function, update editor function

I restore GUI as was, the check is made inside the listener.

I just notice that the editor if statment wasn't correct,

* fix bracket sapce

* fix some spaces and usless  blank lines

* fixes if statment

remove jquery, use plain javascript

* fix space

* fix brackets

* removed jquery line

* fix clang format line 271

* update check for UpdateGuiButtons function

- button are disabled only if weren't already disabled
- same thing for enabling.

* fix format

* move comment

* Update microbe_editor.mjs

* update comment for select button

* update comment of updateSelectedOrganelle

Better explanation for updateSelectedOrganelle function, introducing the concept of button status made in updateGuiButtons

* delete usless check

delete usless and branch of if statment in updateSelectedOrganelle function

* restore comment

* update functions and gui text

- delete select removed class
- change toltip text according to one more scientifically corret

* restore completly old function

* nucleus button has disabled status

- I just forgot that this could be necessary, so nucleus is prevent to be insert more times by guy, and if bypassed by changing the source code there is still the check in as files

* Nucleus name in editor

- i revert htis changment before commit, my bad.

* Rotation for nucleus organelle.

- In renderHighlightedOrganelle method if organelle that is going to be placed is nucleus rotation parameter change to 180 degrees.

- in _addOrganelle method is rotating again in order to have the same rotation of render.

* Nucleus rotation parameters

- removed manual rotation in prodecural_microbe.as
- added one time rotation in nucleus_organelle.as

Now nucleus is in right position both for microbe  controleld by IA and player one, without any modification in editor

* clang format fix

* nucleus rotation for npc

I do not why it works, i also try put 180 degreesin that line and in inserLast organelle few lines later another 180 and i obtain same result

* editor name
  • Loading branch information
Dak2896 authored and hhyyrylainen committed Jan 15, 2019
1 parent 86457cb commit 6879a61
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 13 deletions.
40 changes: 39 additions & 1 deletion scripts/gui/microbe_editor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const organelleSelectionElements = [
{
element: document.getElementById("addChromatophor"),
organelle: "chromatophors"
},
{
element: document.getElementById("addNucleus"),
organelle: "nucleus"
}

// AddPilus
Expand Down Expand Up @@ -126,7 +130,9 @@ export function setupMicrobeEditor(){

element.element.addEventListener("click", (event) => {
event.stopPropagation();
onSelectNewOrganelle(element.organelle);
if(!element.element.classList.contains("DisabledButton")) {
onSelectNewOrganelle(element.organelle);
}
}, true);
}

Expand Down Expand Up @@ -193,6 +199,11 @@ export function setupMicrobeEditor(){
// Event for restoring the microbe GUI
Leviathan.OnGeneric("MicrobeEditorExited", doExitMicrobeEditor);

// Event for update buttons depending on presence or not of nucleus
Leviathan.OnGeneric("MicrobeEditorNucleusIsPresent", (event, vars) => {
updateGuiButtons(vars.nucleus);
});

} else {
updateSelectedOrganelle("cytoplasm");
}
Expand Down Expand Up @@ -287,6 +298,33 @@ function updateGeneration(generation){
generation;
}

//! Updates buttons status depending on presence of nucleus in GUI
function updateGuiButtons(isNucleusPresent){

if(!isNucleusPresent &&
!document.getElementById("addMitochondrion").classList.contains("DisabledButton")) {

document.getElementById("addNucleus").classList.remove("DisabledButton");
document.getElementById("addMitochondrion").classList.add("DisabledButton");
document.getElementById("addChloroplast").classList.add("DisabledButton");
document.getElementById("addChemoplast").classList.add("DisabledButton");
document.getElementById("addNitrogenFixingPlastid").classList.add("DisabledButton");
document.getElementById("addVacuole").classList.add("DisabledButton");
document.getElementById("addToxinVacuole").classList.add("DisabledButton");

} else if(isNucleusPresent &&
document.getElementById("addMitochondrion").classList.contains("DisabledButton")) {

document.getElementById("addNucleus").classList.add("DisabledButton");
document.getElementById("addMitochondrion").classList.remove("DisabledButton");
document.getElementById("addChloroplast").classList.remove("DisabledButton");
document.getElementById("addChemoplast").classList.remove("DisabledButton");
document.getElementById("addNitrogenFixingPlastid").classList.remove("DisabledButton");
document.getElementById("addVacuole").classList.remove("DisabledButton");
document.getElementById("addToxinVacuole").classList.remove("DisabledButton");
}
}

//! Updates generation points in GUI
function updateSpeed(speed){
document.getElementById("speedLabel").textContent =
Expand Down
16 changes: 12 additions & 4 deletions scripts/gui/thrive_gui.html
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
A space or vesicle within the cytoplasm of a cell, enclosed by a membrane and used to hold compounds</span>
<div id="VacuoleIcon"></div>Vacuole<br>30 MP</td>
<td id="addToxinVacuole" class="OrganelleListItem">
<span class="tooltiptext">
<span class="tooltiptext">
Toxin Vacuole <hr><br> Cost: 80 mutation points<hr><br>
Performs Process: OxytoxyNT Production<br>(1 Oxygen + 5 ATP -> 5 Oxytoxy)/Second (Depending On Environmental Oxygen)<hr><br>
Allows for production and storage of OxytoxyNT which can be shot at enemy cells using E. The more of this organelle you have the faster your toxin fire rate aswell.
Expand All @@ -412,10 +412,18 @@
Chemoplast<hr><br> Cost: 40 mutation points<hr><br>
Performs Process: Chemosynthesis<br>(0.09 CO2 + 1 Hydrogen Sulfide -> 2 Glucose)/Second (Depending On Environmental C02)<hr><br>
Allows for synthesis of glucose from hydrogen sulfide and atmospheric carbon dioxide.
<br>
Can be used to process the normally toxic soup containing hydrogen sulfide that comes out of hydrothermal vents at the bottom of the ocean. Into glucose.
</span>
<br>
Can be used to process the normally toxic soup containing hydrogen sulfide that comes out of hydrothermal vents at the bottom of the ocean. Into glucose.
</span>
<div id="ChemoplastIcon"></div>Chemoplast<br>40 MP</td>
<td id="addNucleus" class="OrganelleListItem">
<span class="tooltiptext">
Nucleus<hr><br> Cost: 100 mutation points<hr><br>
Performs Process: Eukaryote Evolution<hr><br>
Allows for synthesis of RNA, MRNA, allows cell to evolve membrane bound organelles.
</span>
<div id="NucleusIcon">
</div>Nucleus <br>100 MP</td>
<td id="addNitrogenFixingPlastid" class="OrganelleListItem">
<span class="tooltiptext">
Nitrogen Fixing Plastid<hr><br> Cost: 80 mutation points<hr><br>
Expand Down
9 changes: 9 additions & 0 deletions scripts/gui/thrive_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,15 @@ video {
top: 15px;
}

#NucleusIcon {
position: relative;
left: calc(50% - 30px);
width: 60px;
height: 60px;
background-size: contain;
background-image: url("../../Textures/gui/bevel/NucleusIcon.png");
}

#CytoplasmIcon {
position: relative;
left: calc(50% - 30px);
Expand Down
4 changes: 1 addition & 3 deletions scripts/microbe_stage/configs.as
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,7 @@ const dictionary STARTER_MICROBES = {
{"oxytoxy", InitialCompound(0)}
},
{
OrganelleTemplatePlaced("nucleus", 0, 0, 180),
OrganelleTemplatePlaced("cytoplasm", 1, 1, 0),
OrganelleTemplatePlaced("cytoplasm", -1, 2, 0)
OrganelleTemplatePlaced("cytoplasm", 0, 0, 0)
},
Float4(1, 1, 1, 1),
false,
Expand Down
33 changes: 33 additions & 0 deletions scripts/microbe_stage/microbe_editor/microbe_editor.as
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class MicrobeEditor{

placementFunctions = {
{"nucleus", PlacementFunctionType(this.createNewMicrobe)},
{"nucleus", PlacementFunctionType(this.addOrganelle)},
{"flagellum", PlacementFunctionType(this.addOrganelle)},
{"cytoplasm", PlacementFunctionType(this.addOrganelle)},
{"mitochondrion", PlacementFunctionType(this.addOrganelle)},
Expand All @@ -69,6 +70,7 @@ class MicrobeEditor{
//! This is called each time the editor is entered so this needs to properly reset state
void init()
{
updateGuiButtonStatus(checkIsNucleusPresent());
gridSceneNode = hudSystem.world.CreateEntity();
auto node = hudSystem.world.Create_RenderNode(gridSceneNode);
node.Scale = Float3(HEX_SIZE, 1, HEX_SIZE);
Expand Down Expand Up @@ -228,6 +230,12 @@ class MicrobeEditor{

private void _addOrganelle(PlacedOrganelle@ organelle)
{
// 1 - you put nucleus but you already have it
// 2 - you put organelle that need nucleus and you don't have it
if((organelle.organelle.name == "nucleus" && checkIsNucleusPresent()) ||
(organelle.organelle.prokaryoteChance == 0 && !checkIsNucleusPresent()) && organelle.organelle.chanceToCreate != 0 )
return;

EditorAction@ action = EditorAction(organelle.organelle.mpCost,
// redo
function(EditorAction@ action, MicrobeEditor@ editor){
Expand Down Expand Up @@ -256,6 +264,9 @@ class MicrobeEditor{
LOG_INFO("Placing organelle '" + organelle.organelle.name + "' at: " +
organelle.q + ", " + organelle.r);
editor.editedMicrobe.insertLast(organelle);

// send to gui current status of cell
editor.updateGuiButtonStatus(editor.checkIsNucleusPresent());
},
// undo
function(EditorAction@ action, MicrobeEditor@ editor){
Expand All @@ -274,6 +285,9 @@ class MicrobeEditor{
}

}

// send to gui current status of cell
editor.updateGuiButtonStatus(editor.checkIsNucleusPresent());
});

@action.data["organelle"] = organelle;
Expand Down Expand Up @@ -562,6 +576,25 @@ class MicrobeEditor{
// LOG_WRITE("Mouse hex: " + qr + ", " + rr);
}

bool checkIsNucleusPresent()
{
for(uint i = 0; i < editedMicrobe.length(); ++i){
auto organelle = cast<PlacedOrganelle>(editedMicrobe[i]);
if (organelle.organelle.name == "nucleus"){
return true;
}
}
return false;
}

void updateGuiButtonStatus(bool nucleusIsPresent){

GenericEvent@ event = GenericEvent("MicrobeEditorNucleusIsPresent");
NamedVars@ vars = event.GetNamedVars();

vars.AddValue(ScriptSafeVariableBlock("nucleus", nucleusIsPresent));
GetEngine().GetEventHandler().CallEvent(event);
}

bool isValidPlacement(const string &in organelleType, int q, int r,
int rotation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NucleusOrganelle : OrganelleComponent{
sceneNode1.Node.setPosition(Hex::axialToCartesian(q + 1, r + 1));
//sceneNode1.Node.setOrientation(Ogre::Quaternion(Ogre::Radian(rotation),
// Ogre::Vector3(0, .5, 1)));
sceneNode1.Node.setOrientation(Ogre::Quaternion(Ogre::Degree(rotation),
sceneNode1.Node.setOrientation(Ogre::Quaternion(Ogre::Degree(rotation+180),
Ogre::Vector3(0, 1, -1)));
sceneNode1.Marked = true;

Expand All @@ -59,7 +59,7 @@ class NucleusOrganelle : OrganelleComponent{
sceneNode2.Scale = Float3(HEX_SIZE, HEX_SIZE, HEX_SIZE);
sceneNode2.Node.setPosition(Hex::axialToCartesian(q, r+.4));

sceneNode2.Node.setOrientation(Ogre::Quaternion(Ogre::Degree(rotation+10),
sceneNode2.Node.setOrientation(Ogre::Quaternion(Ogre::Degree(rotation+190),
Ogre::Vector3(0, 1, -1)));
sceneNode2.Marked = true;

Expand Down
2 changes: 1 addition & 1 deletion scripts/microbe_stage/organelle_table.as
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void setupOrganelles(){
nucleusParameters.mesh = "nucleus.mesh";
nucleusParameters.chanceToCreate = 0; // Not randomly generated.
nucleusParameters.prokaryoteChance = 0; // Not randomly generated.
nucleusParameters.mpCost = 0; //it's not supossed to be purchased.
nucleusParameters.mpCost = 100; //big evolution moment.
nucleusParameters.initialComposition = {
{"phosphates", 2},
{"ammonia", 2}
Expand Down
4 changes: 2 additions & 2 deletions scripts/microbe_stage/procedural_microbes.as
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ array<PlacedOrganelle@>@ positionOrganelles(const string &in stringCode){
const auto letter = CharacterToString(stringCode[i]);
// LOG_WRITE(formatUInt(i) + ": " + letter);
string name = string(organelleLetters[letter]);
//this places the nucleous
//this places the nucleus
if(i == 0){

@pos = OrganelleTemplatePlaced(name, 0, 0, 180);
@pos = OrganelleTemplatePlaced(name, 0, 0, 360);

} else {

Expand Down

0 comments on commit 6879a61

Please sign in to comment.