Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.

Commit

Permalink
アイテム編集機能を実装!
Browse files Browse the repository at this point in the history
ほぼ完成!
  • Loading branch information
sugtao4423 committed Aug 2, 2019
1 parent 4ae9e41 commit 6d77ae0
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 3 deletions.
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
# MHW itemData.itm Editor
But Android Application

You can only view items in itemData.itm yet
You can download from release page

![other](https://pbs.twimg.com/media/EA6dmiPVAAEbp9L.jpg:small)
![jp](https://pbs.twimg.com/media/EA6dmNeUwAAz0bz.jpg:small)
Don't need original `itemData.itm` file

## Built-In itemData.itm
* chunk0
* chunk3
* chunk5
* chunk7
* chunk9
* chunk10

## features
* view items
* edit carry, sell and buy values
* save

## Languages
* English (default)
* Japanese

## screenshots
![](https://pbs.twimg.com/media/EA_Q9nVUEAA91QN.jpg:small)
![](https://pbs.twimg.com/media/EA_Q98xU0AAce83.jpg:small)
![](https://pbs.twimg.com/media/EA_Q-RoUcAIVhLF.jpg:small)

## screenshots (jp)
[ツイートみて](https://twitter.com/sugtao4423/status/1157373360222818304)
37 changes: 37 additions & 0 deletions app/src/main/java/sugtao4423/mhwitemdataeditor/ItemClicked.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package sugtao4423.mhwitemdataeditor

import android.content.Context
import android.support.design.widget.TextInputEditText
import android.support.v7.app.AlertDialog
import android.view.View

class ItemClicked : ItemListAdapter.OnItemClickListener {

override fun onItemClicked(context: Context, itemListAdapter: ItemListAdapter, position: Int) {
val item = itemListAdapter.data[position]

val editorView = View.inflate(context, R.layout.item_edit, null)
val editCarry = editorView.findViewById<TextInputEditText>(R.id.carry)
val editSell = editorView.findViewById<TextInputEditText>(R.id.sell)
val editBuy = editorView.findViewById<TextInputEditText>(R.id.buy)

editCarry.setText(item.carry.toString())
editSell.setText(item.sell.toString())
editBuy.setText(item.buy.toString())

AlertDialog.Builder(context).apply {
setTitle(ItemDataUtils.getItemName(context, item))
setView(editorView)
setNegativeButton(R.string.cancel, null)
setPositiveButton(R.string.ok) { _, _ ->
item.carry = editCarry.text.toString().toInt()
item.sell = editSell.text.toString().toInt()
item.buy = editBuy.text.toString().toInt()

itemListAdapter.notifyItemChanged(position)
}
show()
}
}

}
10 changes: 10 additions & 0 deletions app/src/main/java/sugtao4423/mhwitemdataeditor/ItemListAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import java.util.*

class ItemListAdapter(private val context: Context) : RecyclerView.Adapter<ItemListAdapter.ViewHolder>() {

interface OnItemClickListener {
fun onItemClicked(context: Context, itemListAdapter: ItemListAdapter, position: Int)
}

var onItemClickListener: OnItemClickListener? = null

val data = arrayListOf<ItemData>()
private val numberFormat = NumberFormat.getNumberInstance(Locale.US)

Expand All @@ -28,6 +34,10 @@ class ItemListAdapter(private val context: Context) : RecyclerView.Adapter<ItemL
holder.itemIcon.setImageResource(ItemDataUtils.getItemIconRes(item))
holder.itemName.text = ItemDataUtils.getItemName(context, item)
holder.itemDetail.text = context.getString(R.string.item_detail, item.id, item.carry, numberFormat.format(item.sell), numberFormat.format(item.buy))

holder.itemView.setOnClickListener {
onItemClickListener?.onItemClicked(context, this, position)
}
}

override fun getItemCount(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class MainActivity : AppCompatActivity() {
setSupportActionBar(findViewById(R.id.toolbar))

itemListAdapter = ItemListAdapter(this)
itemListAdapter.onItemClickListener = ItemClicked()
findViewById<ItemDataRecyclerView>(R.id.itemDataRecyclerView).adapter = itemListAdapter

loadItmFile()
Expand Down
68 changes: 68 additions & 0 deletions app/src/main/res/layout/item_edit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">

<android.support.design.widget.TextInputLayout
android:id="@+id/carryLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">

<android.support.design.widget.TextInputEditText
android:id="@+id/carry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/carry"
android:inputType="number"
android:maxLines="1" />

</android.support.design.widget.TextInputLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/carryLayout"
android:layout_marginTop="16dp"
android:baselineAligned="false"
android:orientation="horizontal">

<android.support.design.widget.TextInputLayout
android:id="@+id/sellLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<android.support.design.widget.TextInputEditText
android:id="@+id/sell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="8"
android:hint="@string/sell"
android:inputType="number"
android:maxLines="1" />

</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
android:id="@+id/buyLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<android.support.design.widget.TextInputEditText
android:id="@+id/buy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="8"
android:hint="@string/buy"
android:inputType="number"
android:maxLines="1" />

</android.support.design.widget.TextInputLayout>

</LinearLayout>

</RelativeLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<string name="file_save_failed">保存に失敗しました…</string>

<string name="item_detail">ID: %1$d, 最大個数: %2$d, 売値: %3$sz, 買値: %4$sz</string>
<string name="carry">最大個数</string>
<string name="sell">売値</string>
<string name="buy">買値</string>

<string name="item_0001">回復薬</string>
<string name="item_0002">回復薬グレート</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<string name="permission_rejected" translatable="false">(๑•﹏•๑*)</string>

<string name="item_detail">ID: %1$d, Carry: %2$d, Sell: %3$sz, Buy: %4$sz</string>
<string name="carry">Carry</string>
<string name="sell">Sell</string>
<string name="buy">Buy</string>

<string name="item_0001">Potion</string>
<string name="item_0002">Mega Potion</string>
Expand Down

0 comments on commit 6d77ae0

Please sign in to comment.