new slot on main page for equiped items and redirect to root 📈
continuous-integration/drone/push Build is passing Details

SQLite
Lucas Delanier 2 years ago
parent f21502c844
commit c6341f7e1a

@ -14,6 +14,7 @@ import androidx.navigation.fragment.findNavController
import com.example.shakecraft.model.Player
class HomeFragment : Fragment() {
private lateinit var pseudo : TextView
private lateinit var progressbar : ProgressBar
@ -25,6 +26,7 @@ class HomeFragment : Fragment() {
private lateinit var buttonBoss : ConstraintLayout
private lateinit var buttonForge : ConstraintLayout
private lateinit var playermage : ImageView
private lateinit var equipeditem: ImageView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -42,6 +44,12 @@ class HomeFragment : Fragment() {
return view
}
/*fun loadWeatherDate(){
CoroutineScope(Dispatchers.IO).launch {
val
}
}*/
private fun initializeViews(view: View, currentPlayer : Player) {
pseudo = view.findViewById(R.id.pseudoTextView)
progressbar = view.findViewById(R.id.levelProgressBar)
@ -51,6 +59,7 @@ class HomeFragment : Fragment() {
xp = view.findViewById(R.id.xpTextView)
playermage = view.findViewById(R.id.playerImage)
buttonCollect = view.findViewById(R.id.buttonCollect)
equipeditem = view.findViewById(R.id.equipedItemAttack)
buttonCollect.setOnClickListener{
findNavController().navigate(R.id.action_homeFragment_to_collectFragment, null, NavOptions.Builder().setPopUpTo(R.id.homeFragment, false).build())
}
@ -70,6 +79,8 @@ class HomeFragment : Fragment() {
progressbar.progress = currentPlayer.xp
progressbar.max = currentPlayer.level*100
playermage.setImageResource(currentPlayer.image)
if(currentPlayer.equipedItem?.type?.image != null) equipeditem.setImageResource(
currentPlayer.equipedItem!!.type.image)
}

@ -1,5 +1,4 @@
package com.example.shakecraft
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
@ -24,6 +23,7 @@ class InventoryFragment() : Fragment( ), AdapterInventory.OnItemLongClickListene
override fun onItemLongClick(position: Int) {
if(currentPlayer.items[position] is Tool) {
if (currentPlayer.equipeItem(currentPlayer.items[position]) == true)
Toast.makeText(
context,
currentPlayer.items[position].type.name + " was well equipped",
@ -35,7 +35,6 @@ class InventoryFragment() : Fragment( ), AdapterInventory.OnItemLongClickListene
currentPlayer.items[position].type.name + " has been well unequipped",
Toast.LENGTH_SHORT
).show()
println("equiped item")
setUpRecyclerView(view?.parent as ViewGroup, this)
}
}

@ -9,13 +9,13 @@ import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.navigation.findNavController
import androidx.navigation.ui.NavigationUI
import androidx.navigation.ui.setupWithNavController
import com.example.shakecraft.data.Stub
import com.google.android.material.bottomnavigation.BottomNavigationView
class MainActivity : AppCompatActivity() {
class MainActivity: AppCompatActivity() {
var currentPlayer = Stub().load()
@ -43,10 +43,22 @@ class MainActivity : AppCompatActivity() {
bottomNav = findViewById(R.id.bottomNavigationView)
val navController = findNavController(R.id.fragment)
navController.popBackStack(R.id.fragment, false)
bottomNav.setupWithNavController(navController)
bottomNav.setOnItemReselectedListener { item ->
// Pop everything up to the reselected item
val reselectedDestinationId = item.itemId
navController.popBackStack(reselectedDestinationId, inclusive = false)
}
bottomNav.setOnItemSelectedListener { item ->
NavigationUI.onNavDestinationSelected(item, navController)
true
}
}
override fun onResume() {
super.onResume()

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/black_800"/>
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"/>
<stroke android:width="1dp"
android:color="@color/grey_100" />
</shape>

@ -66,7 +66,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp"
android:layout_marginTop="15dp"
android:layout_marginLeft="15dp"
android:orientation="vertical">
<TextView
@ -149,6 +150,48 @@
android:textColor="@color/white"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/equipedItemAttack"
android:tooltipText="Equiped Weapon"
android:layout_gravity="bottom"
android:background="@drawable/background_equiped_item"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="Landscape"
android:layout_marginRight="10dp"/>
<ImageView
android:tooltipText="Equiped Fishing Rod"
android:id="@+id/equipedItemFishing"
android:layout_gravity="bottom"
android:background="@drawable/background_equiped_item"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="Landscape"
android:layout_marginRight="10dp"/>
<ImageView
android:id="@+id/equipedItemCollect"
android:tooltipText="Equiped Tool"
android:layout_gravity="bottom"
android:background="@drawable/background_equiped_item"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="Landscape"
android:layout_marginRight="10dp"/>
<ImageView
android:id="@+id/equipedItemArmor"
android:tooltipText="Equiped Armor"
android:layout_gravity="bottom"
android:background="@drawable/background_equiped_item"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="Landscape"
android:layout_marginRight="10dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

@ -48,7 +48,11 @@
<action
android:id="@+id/action_homeFragment_to_collectFragment"
app:destination="@id/collectFragment"
app:enterAnim="@android:anim/fade_in" />
app:enterAnim="@android:anim/fade_in"
app:popUpTo="@id/homeFragment"
app:popUpToInclusive="true"
app:popUpToSaveState="true"
app:restoreState="true" />
<action
android:id="@+id/action_homeFragment_to_bossFragment"
app:destination="@id/bossFragment"

Loading…
Cancel
Save