Commit 05b0cc03 authored by fallenstardust's avatar fallenstardust

为mobile卡组编辑制作禁限图标,移除无用的imageTop_genesys类、tLim、tLimCredit引用

parent 57892a2b
......@@ -1609,7 +1609,7 @@ void Game::DrawThumb(code_pointer cp, irr::core::vector2di pos, const LFList* lf
else if(cp->second.ot & AVAIL_TCG)
driver->draw2DImage(imageManager.tOT, otloc, irr::core::recti(0, 64, 128, 128), 0, 0, true);
else if(!avail)
driver->draw2DImage(imageManager.tLim, otloc, irr::core::recti(0, 0, 64, 64), 0, 0, true);
driver->draw2DImage(imageManager.tLimit, otloc, irr::core::recti(64, 0, 128, 64), 0, 0, true);
}
}
......
......@@ -34,8 +34,6 @@ bool ImageManager::Initial(const path dir) {
tEquip = driver->getTexture((dir + path("/textures/equip.png")).c_str());
tTarget = driver->getTexture((dir + path("/textures/target.png")).c_str());
tChainTarget = driver->getTexture((dir + path("/textures/chaintarget.png")).c_str());
tLim = driver->getTexture((dir + path("/textures/lim.png")).c_str());
tLimCredit = driver->getTexture((dir + path("/textures/lim_credit.png")).c_str());
tLimit = driver->getTexture((dir + path("/textures/icon_lim.png")).c_str());
tOT = driver->getTexture((dir + path("/textures/ot.png")).c_str());
tHand[0] = driver->getTexture((dir + path("/textures/f1.jpg")).c_str());
......
......@@ -46,8 +46,6 @@ public:
irr::video::ITexture* tEquip;
irr::video::ITexture* tTarget;
irr::video::ITexture* tChainTarget;
irr::video::ITexture* tLim;
irr::video::ITexture* tLimCredit;
irr::video::ITexture* tLimit;
irr::video::ITexture* tOT;
irr::video::ITexture* tHand[3];
......
......@@ -72,7 +72,7 @@ public interface Constants {
String ASSETS_PT = "pt/";
String ASSETS_PATH = "data/";
String ASSET_SERVER_LIST = "serverlist.xml";
String ASSET_LIMIT_PNG = ASSETS_PATH + "textures/lim.png";
String ASSET_LIMIT_PNG = ASSETS_PATH + "textures/icon_lim.png";
String ASSET_GENESYS_LIMIT_PNG = ASSETS_PATH + "textures/lim_credit.png";
String DEFAULT_FONT_NAME = "ygo.ttf";
String DATABASE_NAME = "cards.cdb";
......
package cn.garymb.ygomobile.ui.adapters;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
......@@ -17,8 +16,8 @@ import cn.garymb.ygomobile.loader.ImageLoader;
import cn.garymb.ygomobile.ui.activities.BaseActivity;
import cn.garymb.ygomobile.ui.cards.CardListProvider;
import cn.garymb.ygomobile.ui.cards.deck.ImageTop;
import cn.garymb.ygomobile.ui.cards.deck.ImageTop_GeneSys;
import cn.garymb.ygomobile.utils.CardUtils;
import cn.garymb.ygomobile.utils.YGOUtil;
import ocgcore.DataManager;
import ocgcore.StringManager;
import ocgcore.data.Card;
......@@ -29,7 +28,7 @@ import ocgcore.enums.LimitType;
public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, BaseViewHolder> implements CardListProvider {
private final StringManager mStringManager;
private ImageTop mImageTop;
private ImageTop_GeneSys mImageTop_GeneSys;
private TextView tv_limit_num;
private LimitList mLimitList;
private boolean mItemBg;
private final ImageLoader imageLoader;
......@@ -100,8 +99,6 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, BaseViewHolde
}
private int getColor(int id) {
return context.getResources().getColor(id);
}
......@@ -135,6 +132,7 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, BaseViewHolde
private View mShowMenuView;
@Override
protected void convert(com.chad.library.adapter.base.viewholder.BaseViewHolder holder, Card item) {
int position = holder.getBindingAdapterPosition() - getHeaderLayoutCount();
......@@ -187,29 +185,39 @@ public class CardListAdapter extends BaseRecyclerAdapterPlus<Card, BaseViewHolde
if (mImageTop == null) {
mImageTop = new ImageTop(context);
}
if (mImageTop_GeneSys == null) {
mImageTop_GeneSys = new ImageTop_GeneSys(context);
}
TextView tv_limit_num = holder.getView(R.id.tv_limit_num);//创建该布局的对象,以便对它的字体颜色,大小,文本进行自由设置
if (mLimitList != null) {
holder.setGone(R.id.right_top, false);
if (mLimitList.check(item, LimitType.Forbidden)) {
holder.setImageBitmap(R.id.right_top, mImageTop.forbidden);
tv_limit_num.setText("");
} else if (mLimitList.check(item, LimitType.Limit)) {
holder.setImageBitmap(R.id.right_top, mImageTop.limit);
tv_limit_num.setText("1");
tv_limit_num.setTextSize(12);
tv_limit_num.setTextColor(YGOUtil.c(R.color.yellow));
} else if (mLimitList.check(item, LimitType.SemiLimit)) {
holder.setImageBitmap(R.id.right_top, mImageTop.semiLimit);
tv_limit_num.setText("2");
tv_limit_num.setTextSize(12);
tv_limit_num.setTextColor(YGOUtil.c(R.color.yellow));
} else if (mLimitList.check(item, LimitType.GeneSys)) {
Integer creditValue = 0;
if (mLimitList.getCredits() != null) {
creditValue = mLimitList.getCredits().get(item.Alias == 0 ? item.Code : item.Alias);
holder.setImageBitmap(R.id.right_top, mImageTop_GeneSys.geneSysLimit.get(creditValue - 1));
holder.setImageBitmap(R.id.right_top, mImageTop.credits);
tv_limit_num.setText(creditValue.toString());
tv_limit_num.setTextSize((creditValue > -10 && creditValue < 100) ? 10 : 8);
tv_limit_num.setTextColor(YGOUtil.c(R.color.holo_blue_bright));
}
} else {
holder.setGone(R.id.right_top, true);
holder.setText(R.id.tv_limit_num, "");
}
} else {
holder.setGone(R.id.right_top, true);
holder.setText(R.id.tv_limit_num, "");
}
//卡片类型
holder.setText(R.id.card_type, CardUtils.getAllTypeString(item, mStringManager));
......@@ -234,7 +242,7 @@ class ViewHolder extends BaseRecyclerAdapterPlus.BaseViewHolder {
TextView cardDef;
TextView TextDef;
TextView cardScale;
TextView tv_limit_num;
ImageView rightImage;
View layout_atk;
View layout_def;
......@@ -264,6 +272,7 @@ class ViewHolder extends BaseRecyclerAdapterPlus.BaseViewHolder {
layout_def = $(R.id.layout_def);
view_bar = $(R.id.view_bar);
rightImage = $(R.id.right_top);
tv_limit_num = $(R.id.tv_limit_num);
codeView = $(R.id.card_code);
TextDef = $(R.id.TextDef);
btnMain = $(R.id.btn_add_main);
......
......@@ -8,6 +8,7 @@ import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
......@@ -27,6 +28,7 @@ import cn.garymb.ygomobile.loader.DeckLoader;
import cn.garymb.ygomobile.loader.ImageLoader;
import cn.garymb.ygomobile.ui.cards.CardListProvider;
import cn.garymb.ygomobile.utils.CardSort;
import cn.garymb.ygomobile.utils.YGOUtil;
import ocgcore.data.Card;
import ocgcore.data.LimitList;
import ocgcore.enums.CardType;
......@@ -45,7 +47,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
private final Random mRandom;
private final ImageLoader imageLoader;
private ImageTop mImageTop;
private ImageTop_GeneSys mImageTop_GeneSys;
private TextView tv_deck_limit_num;
private int mMainCount;
private int mExtraCount;
private int mSideCount;
......@@ -636,27 +638,30 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
if (mImageTop == null) {
mImageTop = new ImageTop(context);
}
if (mImageTop_GeneSys == null) {
mImageTop_GeneSys = new ImageTop_GeneSys(context);
}
if (mLimitList != null) {
if (mLimitList.check(cardInfo, LimitType.Forbidden)) {
holder.setRightImage(mImageTop.forbidden);
holder.setLimitText("", YGOUtil.c(R.color.white), 10);
} else if (mLimitList.check(cardInfo, LimitType.Limit)) {
holder.setRightImage(mImageTop.limit);
holder.setLimitText("1", YGOUtil.c(R.color.yellow), 10);
} else if (mLimitList.check(cardInfo, LimitType.SemiLimit)) {
holder.setRightImage(mImageTop.semiLimit);
holder.setLimitText("2", YGOUtil.c(R.color.yellow), 10);
} else if (mLimitList.check(cardInfo, LimitType.GeneSys)) {
Integer creditValue = 0;
if (mLimitList.getCredits() != null) {
creditValue = mLimitList.getCredits().get(cardInfo.Alias == 0 ? cardInfo.Code : cardInfo.Alias);
holder.setRightImage(mImageTop_GeneSys.geneSysLimit.get(creditValue - 1));
holder.setRightImage(mImageTop.credits);
holder.setLimitText(creditValue.toString(), YGOUtil.c(R.color.holo_blue_bright), (creditValue > -10 && creditValue < 100) ? 8 : 6);
}
} else {
holder.setRightImage(null);
holder.setLimitText("", YGOUtil.c(R.color.white), 10);
}
} else {
holder.setRightImage(null);
holder.setLimitText("", YGOUtil.c(R.color.white), 10);
}
// holder.useDefault();
imageLoader.bindImage(holder.cardImage, cardInfo, ImageLoader.Type.small);
......
......@@ -21,6 +21,7 @@ class DeckViewHolder extends RecyclerView.ViewHolder {
private final View headView;
private final View textlayout;
private final TextView labelText;
private final TextView tv_deck_limit_num;
public final ImageView cardImage;
private final ImageView rightImage;
......@@ -38,6 +39,7 @@ class DeckViewHolder extends RecyclerView.ViewHolder {
rightImage = $(R.id.right_top);
labelText = $(R.id.label);
textlayout = $(R.id.layout_label);
tv_deck_limit_num = $(R.id.tv_deck_limit_num);
headView = null;// $(R.id.head);
}
......@@ -105,7 +107,11 @@ class DeckViewHolder extends RecyclerView.ViewHolder {
cardImage.setVisibility(View.GONE);
rightImage.setVisibility(View.GONE);
}
public void setLimitText(String text, int color, int textSize) {
tv_deck_limit_num.setText(text);
tv_deck_limit_num.setTextColor(color);
tv_deck_limit_num.setTextSize(textSize);
}
/**
* 展示卡图,隐藏分隔标签
*/
......
......@@ -11,6 +11,7 @@ public class ImageTop {
public final Bitmap forbidden;
public final Bitmap limit;
public final Bitmap semiLimit;
public final Bitmap credits;
public ImageTop(Context context) {
this(BitmapUtil.getBitmapFormAssets(context, ASSET_LIMIT_PNG, 0, 0));
......@@ -22,11 +23,13 @@ public class ImageTop {
int height = img.getHeight();
forbidden = Bitmap.createBitmap(img, 0, 0, width / 2, height / 2);
limit = Bitmap.createBitmap(img, width / 2, 0, width / 2, height / 2);
semiLimit = Bitmap.createBitmap(img, 0, height / 2, width / 2, height / 2);
semiLimit = Bitmap.createBitmap(img, width / 2, 0, width / 2, height / 2);
credits = Bitmap.createBitmap(img, 0, height / 2, width / 2, height / 2);
} else {
forbidden = null;
limit = null;
semiLimit = null;
credits = null;
}
BitmapUtil.destroy(img);
}
......@@ -35,5 +38,6 @@ public class ImageTop {
BitmapUtil.destroy(forbidden);
BitmapUtil.destroy(limit);
BitmapUtil.destroy(semiLimit);
BitmapUtil.destroy(credits);
}
}
package cn.garymb.ygomobile.ui.cards.deck;
import static cn.garymb.ygomobile.Constants.ASSET_GENESYS_LIMIT_PNG;
import android.content.Context;
import android.graphics.Bitmap;
import java.util.ArrayList;
import java.util.List;
import cn.garymb.ygomobile.utils.BitmapUtil;
public class ImageTop_GeneSys {
public final List<Bitmap> geneSysLimit;
public ImageTop_GeneSys(Context context) {
this(BitmapUtil.getBitmapFormAssets(context, ASSET_GENESYS_LIMIT_PNG, 0, 0));
}
public ImageTop_GeneSys(Bitmap img) {
if (img != null) {
geneSysLimit = new ArrayList<>();
int width = img.getWidth();
int height = img.getHeight();
int itemWidth = width / 10; // 每个小图标的宽度
int itemHeight = height / 10; // 每个小图标的高度
// 按10行10列切割图片
for (int row = 0; row < 10; row++) {
for (int col = 0; col < 10; col++) {
int x = col * itemWidth; // 当前列的起始x坐标
int y = row * itemHeight; // 当前行的起始y坐标
Bitmap item = Bitmap.createBitmap(img, x, y, itemWidth, itemHeight);
geneSysLimit.add(item);//注意索引从0开始,图标号从1开始
}
}
} else {
geneSysLimit = null;
}
BitmapUtil.destroy(img);
}
public void clear() {
for (Bitmap bitmap : geneSysLimit) {
BitmapUtil.destroy(bitmap);
}
}
}
......@@ -17,7 +17,6 @@ import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.loader.ImageLoader;
import cn.garymb.ygomobile.ui.cards.deck.ImageTop;
import cn.garymb.ygomobile.ui.cards.deck.ImageTop_GeneSys;
import ocgcore.data.Card;
import ocgcore.data.LimitList;
......@@ -270,11 +269,11 @@ public class CardGroupView extends FrameLayout {
}
public void updateTopImage(ImageTop imageTop, ImageTop_GeneSys imageTop_GeneSys, LimitList limitList) {
public void updateTopImage(ImageTop imageTop, LimitList limitList) {
int count = getChildCount();
for (int i = 0; i < count; i++) {
CardView cardView = (CardView) getChildAt(i);
cardView.updateLimit(imageTop, imageTop_GeneSys, limitList);
cardView.updateLimit(imageTop, limitList);
}
}
}
......@@ -14,7 +14,6 @@ import androidx.annotation.Nullable;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.loader.ImageLoader;
import cn.garymb.ygomobile.ui.cards.deck.ImageTop;
import cn.garymb.ygomobile.ui.cards.deck.ImageTop_GeneSys;
import ocgcore.data.Card;
import ocgcore.data.LimitList;
import ocgcore.enums.LimitType;
......@@ -72,7 +71,7 @@ public class CardView extends FrameLayout {
}
}
public void updateLimit(ImageTop imageTop, ImageTop_GeneSys imageTop_GeneSys, LimitList limitList) {
public void updateLimit(ImageTop imageTop, LimitList limitList) {
if (mCard != null && imageTop != null) {
mTopImage.setVisibility(View.VISIBLE);
if (limitList != null) {
......@@ -84,20 +83,15 @@ public class CardView extends FrameLayout {
mTopImage.setImageBitmap(imageTop.semiLimit);
} else if (limitList.check(mCard, LimitType.GeneSys)) {
// 根据credits中的信用分值设置对应的图标
if (imageTop_GeneSys != null && imageTop_GeneSys.geneSysLimit != null && !imageTop_GeneSys.geneSysLimit.isEmpty()) {
// 获取卡牌的信用分值
Integer creditValue = 0;
if (limitList.getCredits() != null) {
creditValue = limitList.getCredits().get(mCard.Alias == 0 ? mCard.Code : mCard.Alias);
Log.d("cc","CreditValue: " + creditValue);
Log.d("cc", "CreditValue: " + creditValue);
}
// 根据信用分值设置对应的图标索引
if (creditValue != null && creditValue > 0 && creditValue <= imageTop_GeneSys.geneSysLimit.size()) {
mTopImage.setImageBitmap(imageTop_GeneSys.geneSysLimit.get(creditValue - 1)); // 索引从0开始
} else {
mTopImage.setVisibility(View.GONE);
}
if (creditValue != null && creditValue > 0) {
mTopImage.setImageBitmap(imageTop.credits); // 索引从0开始
} else {
mTopImage.setVisibility(View.GONE);
}
......
......@@ -6,7 +6,6 @@ import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.Toast;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
......@@ -22,7 +21,6 @@ import cn.garymb.ygomobile.bean.DeckInfo;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.loader.ImageLoader;
import cn.garymb.ygomobile.ui.cards.deck.ImageTop;
import cn.garymb.ygomobile.ui.cards.deck.ImageTop_GeneSys;
import cn.garymb.ygomobile.ui.cards.deck.LabelInfo;
import cn.garymb.ygomobile.utils.YGOUtil;
import ocgcore.data.Card;
......@@ -33,7 +31,6 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
private final LabelInfo mLabelInfo;
private final DeckInfo mDeckInfo;
private final ImageTop mImageTop;
private final ImageTop_GeneSys mImageTop_GeneSys;
private LimitList mLimitList;
private final int mainTop;
private final int extraTop;
......@@ -79,7 +76,6 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
mLabelInfo = new LabelInfo(context);
mDeckInfo = new DeckInfo();
mImageTop = new ImageTop(getContext());
mImageTop_GeneSys = new ImageTop_GeneSys(getContext());
if (mCardWidth <= 0) {
int width = (getMeasuredWidth() - getPaddingLeft() - getPaddingRight());
mCardWidth = width / 10;
......@@ -200,9 +196,6 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
public ImageTop getImageTop() {
return mImageTop;
}
public ImageTop_GeneSys getmImageTop_GeneSys() {
return mImageTop_GeneSys;
}
public void setDeck(DeckInfo deck) {
setEditMode(EditMode.None);
......@@ -277,7 +270,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
count--;
}
if (mLimitChanged) {
cardView.updateLimit(getImageTop(), getmImageTop_GeneSys(), mLimitList);
cardView.updateLimit(getImageTop(), mLimitList);
}
} else {
cardView.showCard(mImageLoader, null);
......@@ -307,7 +300,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
}
if (mLimitChanged) {
mMainViews.get(i).updateLimit(getImageTop(), getmImageTop_GeneSys(), mLimitList);
mMainViews.get(i).updateLimit(getImageTop(), mLimitList);
}
} else {
cardView.showCard(mImageLoader, null);
......@@ -327,7 +320,7 @@ public class DeckGroupView extends FrameLayout implements View.OnClickListener {
count--;
}
if (mLimitChanged) {
cardView.updateLimit(getImageTop(), getmImageTop_GeneSys(), mLimitList);
cardView.updateLimit(getImageTop(), mLimitList);
}
} else {
cardView.showCard(mImageLoader, null);
......
......@@ -9,7 +9,6 @@ import androidx.annotation.Nullable;
import cn.garymb.ygomobile.bean.DeckInfo;
import cn.garymb.ygomobile.loader.ImageLoader;
import cn.garymb.ygomobile.ui.cards.deck.ImageTop;
import cn.garymb.ygomobile.ui.cards.deck.ImageTop_GeneSys;
import cn.garymb.ygomobile.ui.cards.deck.LabelInfo;
import ocgcore.data.Card;
import ocgcore.data.LimitList;
......@@ -20,7 +19,6 @@ public class DeckView extends LinearLayout {
private final LabelInfo mLabelInfo;
private LimitList mLimitList;
private final ImageTop mImageTop;
private final ImageTop_GeneSys mImageTop_GeneSys;
private boolean mAutoSort, mEditMode, mLimitChanged;
private ImageLoader mImageLoader;
......@@ -38,7 +36,6 @@ public class DeckView extends LinearLayout {
super(context, attrs, defStyleAttr);
setOrientation(VERTICAL);
mImageTop = new ImageTop(getContext());
mImageTop_GeneSys = new ImageTop_GeneSys(getContext());
mLabelInfo = new LabelInfo(context);
mMainLabel = new DeckLabel(context);
mExtraLabel = new DeckLabel(context);
......@@ -84,9 +81,6 @@ public class DeckView extends LinearLayout {
public ImageTop getImageTop() {
return mImageTop;
}
public ImageTop_GeneSys getImageTop_GeneSys() {
return mImageTop_GeneSys;
}
public boolean isAutoSort() {
return mAutoSort;
......@@ -161,9 +155,9 @@ public class DeckView extends LinearLayout {
mExtraLabel.setText(mLabelInfo.getExtraString());
mSideLabel.setText(mLabelInfo.getSideString());
if (mLimitChanged) {
mMainGroup.updateTopImage(getImageTop(), getImageTop_GeneSys(), mLimitList);
mExtraGroup.updateTopImage(getImageTop(), getImageTop_GeneSys(), mLimitList);
mSideGroup.updateTopImage(getImageTop(), getImageTop_GeneSys(), mLimitList);
mMainGroup.updateTopImage(getImageTop(), mLimitList);
mExtraGroup.updateTopImage(getImageTop(), mLimitList);
mSideGroup.updateTopImage(getImageTop(), mLimitList);
}
mLimitChanged = false;
}
......
......@@ -41,4 +41,14 @@
android:visibility="visible"
app:srcCompat="@drawable/ic_close_black_24dp" />
<TextView
android:id="@+id/tv_deck_limit_num"
android:layout_width="@dimen/right_size2"
android:layout_height="@dimen/right_size2"
android:layout_alignParentRight="true"
android:textSize="8sp"
android:gravity="center"
android:textStyle="bold"
android:visibility="visible" />
</RelativeLayout>
\ No newline at end of file
......@@ -24,7 +24,7 @@
android:background="@drawable/list_item_bg"
android:gravity="center"
android:src="@drawable/ic_to_main"
android:tooltipText="@string/card_add_main"/>
android:tooltipText="@string/card_add_main" />
<View
android:layout_width="0dp"
......@@ -40,7 +40,7 @@
android:background="@drawable/list_item_bg"
android:gravity="center"
android:src="@drawable/ic_to_side"
android:tooltipText="@string/card_add_side"/>
android:tooltipText="@string/card_add_side" />
</LinearLayout>
<LinearLayout
......@@ -70,6 +70,16 @@
android:layout_alignParentRight="true"
android:visibility="visible"
tools:src="@drawable/ic_close_black_24dp" />
<TextView
android:id="@+id/tv_limit_num"
android:layout_width="@dimen/right_size"
android:layout_height="@dimen/right_size"
android:layout_alignParentRight="true"
android:gravity="center"
android:textSize="10sp"
android:textStyle="bold"
android:visibility="visible" />
</RelativeLayout>
<LinearLayout
......
......@@ -17,6 +17,7 @@
<color name="red">#EF3934</color>
<color name="colorAccent">@color/red</color>
<color name="colorAccentDark">#CF3934</color>
<color name="yellow">#FFFF00</color>
<color name="item_title">@color/gold</color>
<color name="item_bg">#65ffffff</color>
<color name="item_bg2">#70ffffff</color>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment