Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
Add Attack Damage and improve design
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLuckyCoder committed Jul 10, 2016
1 parent e70beeb commit 8d93a50
Show file tree
Hide file tree
Showing 12 changed files with 408 additions and 364 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void onCheckboxClicked(View view) {
}
}

public void createMod(View view) {
public void createClass(View view) {
//Strings and Integers
String classNameTxt = etClassName.getText().toString();
String descriptionIdTxt = etDescriptionId.getText().toString();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/smartdev/classmaker/BlockMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected void onCreate(Bundle savedInstanceState) {
etDestroyTime = (EditText) findViewById(R.id.blockDestroyTimeTxt);
}

public void createMod (View view) {
public void createClass(View view) {
//Strings and Integers
String classNameTxt = etClassName.getText().toString();
String descriptionIdTxt = etDescriptionId.getText().toString();
Expand Down
54 changes: 41 additions & 13 deletions app/src/main/java/com/smartdev/classmaker/ItemMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
public class ItemMaker extends AppCompatActivity {

private boolean bCustomMaxStackSize = false,
bCustomAttackDamage = false,
bStackedByData = false;
private EditText etClassName, etDescriptionId, etCategory, etTexture, etMaxStackSize;
private EditText etClassName, etDescriptionId, etCategory, etTexture, etMaxStackSize, etAttackDamage;
String itemHeaderPath;

@Override
Expand All @@ -35,36 +36,49 @@ protected void onCreate(Bundle savedInstanceState) {
etCategory = (EditText) findViewById(R.id.itemCategoryTxt);
etTexture = (EditText) findViewById(R.id.itemTextureTxt);
etMaxStackSize = (EditText) findViewById(R.id.itemMaxStackSizeTxt);
etAttackDamage = (EditText) findViewById(R.id.itemAttackDamageTxt);
}

public void onCheckboxClicked(View view) {
boolean checked = ((CheckBox) view).isChecked();

EditText maxStackSize = (EditText) findViewById(R.id.itemMaxStackSizeTxt);
assert maxStackSize != null;

// Check which checkbox was clicked
switch (view.getId()) {
case R.id.customStackSizeCheck:
if (checked) {
maxStackSize.setVisibility(View.VISIBLE);
etMaxStackSize.setVisibility(View.VISIBLE);
bCustomMaxStackSize = true;
} else {
maxStackSize.setVisibility(View.GONE);
etMaxStackSize.setVisibility(View.GONE);
bCustomMaxStackSize = false;
}
break;
case R.id.stackedByDataCheck:
bStackedByData = checked;
break;
case R.id.customAttackDamageCheck:
if (checked) {
etAttackDamage.setVisibility(View.VISIBLE);
bCustomAttackDamage = true;
} else {
etAttackDamage.setVisibility(View.GONE);
bCustomAttackDamage = false;
}
break;
}
}

public void createMod(View view) {
public void createClass(View view) {
//Strings and Integers
String classNameTxt = etClassName.getText().toString();
String descriptionIdTxt = etDescriptionId.getText().toString();
String categoryTxt = etCategory.getText().toString();
String textureTxt = etTexture.getText().toString();
String maxStackSizeTxt = etMaxStackSize.getText().toString();
int maxStackSizeInt = 64;
String attackDamageTxt = etAttackDamage.getText().toString();
String headerAttackDamageTxt = "";
int maxStackSizeInt = 0;
float attackDamageFloat = 0f;
String stackedByDataTxt = "";

switch (categoryTxt) {
Expand Down Expand Up @@ -96,6 +110,18 @@ else if (maxStackSizeInt == 0)
maxStackSizeTxt = "";
}

if (bCustomAttackDamage) {
if (!attackDamageTxt.matches(""))
attackDamageFloat = Float.parseFloat(attackDamageTxt);

attackDamageTxt = "\n" + classNameTxt + "::getAttackDamage() {\n" +
"\treturn " + attackDamageFloat + ";\n" +
"}\n";
headerAttackDamageTxt = "\n\tvirtual float getAttackDamage();\n";
} else {
attackDamageTxt = "";
}

if (bStackedByData)
stackedByDataTxt = "\tsetStackedByData(true);\n";

Expand All @@ -104,25 +130,27 @@ else if (maxStackSizeInt == 0)
File headerFile = new File(Utils.folderPath + classNameTxt + ".h");
File sourceFile = new File(Utils.folderPath + classNameTxt + ".cpp");

String[] headerFileString = String.valueOf("#pragma once\n\n" +
String[] headerFileContent = String.valueOf("#pragma once\n\n" +
"#include \"" + itemHeaderPath + "\"\n\n" +
"class " + classNameTxt + " : public Item {\n" +
"public:\n" +
"\t" + classNameTxt + "(short itemId);\n" +
headerAttackDamageTxt +
"};\n").split(System.getProperty("line.separator"));

String[] sourceFileString = String.valueOf("#include \"" + classNameTxt + ".h\"\n\n" +
String[] sourceFileContent = String.valueOf("#include \"" + classNameTxt + ".h\"\n\n" +
classNameTxt + "::" + classNameTxt + "(short itemId) : Item(\"" + descriptionIdTxt + "\", " + "itemId - 256) {\n" +
"\tItem::mItems[itemId] = this;\n" +
"\tsetIcon(" + textureTxt + ");\n" +
"\tsetCategory(CreativeItemCategory::" + categoryTxt + ");\n" +
maxStackSizeTxt +
stackedByDataTxt +
"}\n").split(System.getProperty("line.separator"));
"}\n" +
attackDamageTxt).split(System.getProperty("line.separator"));

if (!classNameTxt.matches("")) {
Utils.Save(headerFile, headerFileString);
Utils.Save(sourceFile, sourceFileString);
Utils.Save(headerFile, headerFileContent);
Utils.Save(sourceFile, sourceFileContent);
Snackbar.make(view, R.string.class_successfully_generated, Snackbar.LENGTH_LONG).show();
} else {
Snackbar.make(view, R.string.error_empty_mod_name, Snackbar.LENGTH_LONG).show();
Expand Down
21 changes: 2 additions & 19 deletions app/src/main/java/com/smartdev/classmaker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

Expand Down Expand Up @@ -59,21 +56,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
startActivity(new Intent(MainActivity.this, SettingsActivity.class));
return true;
default:
return super.onOptionsItemSelected(item);
}
public void startSettings(View view) {
startActivity(new Intent(MainActivity.this, SettingsActivity.class));
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#ffffff"
android:pathData="M22.7,19l-9.1,-9.1c0.9,-2.3 0.4,-5 -1.5,-6.9 -2,-2 -5,-2.4 -7.4,-1.3L9,6 6,9 1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1,0.4 1.4,0l2.3,-2.3c0.5,-0.4 0.5,-1.1 0.1,-1.4z"/>
</vector>
Loading

0 comments on commit 8d93a50

Please sign in to comment.