remove unused code and fixed warning.

This commit is contained in:
Dhilan007 2014-03-26 14:11:40 +08:00
parent 1247760d95
commit fa91bf1167
9 changed files with 15 additions and 66 deletions

View File

@ -1072,9 +1072,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
}
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
bool requestUnsupported = textDefinition._shadow._shadowEnabled || textDefinition._stroke._strokeEnabled;
CCASSERT(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!");
CCASSERT(textDefinition._stroke._strokeEnabled == false, "Currently stroke only supported on iOS and Android!");
#endif
PixelFormat pixelFormat = g_defaultAlphaPixelFormat;
@ -1089,8 +1087,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
textDef._dimensions.width *= contentScaleFactor;
textDef._dimensions.height *= contentScaleFactor;
textDef._stroke._strokeSize *= contentScaleFactor;
textDef._shadow._shadowOffset.width *= contentScaleFactor;
textDef._shadow._shadowOffset.height *= contentScaleFactor;
textDef._shadow._shadowEnabled = false;
Data outData = Device::getTextureDataForText(text,textDef,align,imageWidth,imageHeight);
if(outData.isNull())

View File

@ -36,8 +36,6 @@ import android.view.ViewGroup;
import android.util.Log;
import android.widget.FrameLayout;
import java.io.File;
public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener {
// ===========================================================
// Constants
@ -138,14 +136,14 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
// FrameLayout
ViewGroup.LayoutParams framelayout_params =
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT);
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
FrameLayout framelayout = new FrameLayout(this);
framelayout.setLayoutParams(framelayout_params);
// Cocos2dxEditText layout
ViewGroup.LayoutParams edittext_layout_params =
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
Cocos2dxEditText edittext = new Cocos2dxEditText(this);
edittext.setLayoutParams(edittext_layout_params);

View File

@ -39,7 +39,6 @@ import android.graphics.Rect;
import android.graphics.Typeface;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.FloatMath;
import android.util.Log;
public class Cocos2dxBitmap {
@ -119,7 +118,7 @@ public class Cocos2dxBitmap {
*/
if(0 != width)
{
final int firstWordWidth = (int) FloatMath.ceil(paint.measureText(string, 0,1));
final int firstWordWidth = (int) Math.ceil(paint.measureText(string, 0,1));
if ( firstWordWidth > width)
{
Log.w("createTextBitmapShadowStroke warning:","the input width is less than the width of the pString's first word\n");
@ -140,25 +139,6 @@ public class Cocos2dxBitmap {
float renderTextDeltaX = 0.0f;
float renderTextDeltaY = 0.0f;
if ( shadow ) {
int shadowColor = ((int)(255 * shadowOpacity) & 0xff) << 24;
paint.setShadowLayer(shadowBlur, shadowDX, shadowDY, shadowColor);
bitmapPaddingX = Math.abs(shadowDX);
bitmapPaddingY = Math.abs(shadowDY);
if ( shadowDX < 0.0 )
{
renderTextDeltaX = bitmapPaddingX;
}
if ( shadowDY < 0.0 )
{
renderTextDeltaY = bitmapPaddingY;
}
}
if (0 == textProperty.mMaxWidth || 0 == bitmapTotalHeight)
{
Log.w("createTextBitmapShadowStroke warning:","textProperty MaxWidth is 0 or bitMapTotalHeight is 0\n");
@ -272,7 +252,7 @@ public class Cocos2dxBitmap {
/* Compute the max width. */
int temp = 0;
for (final String line : lines) {
temp = (int) FloatMath.ceil(paint.measureText(line, 0,
temp = (int) Math.ceil(paint.measureText(line, 0,
line.length()));
if (temp > maxContentWidth) {
maxContentWidth = temp;
@ -346,7 +326,7 @@ public class Cocos2dxBitmap {
* The width of line is exceed maxWidth, should divide it into
* two or more lines.
*/
final int lineWidth = (int) FloatMath.ceil(paint
final int lineWidth = (int) Math.ceil(paint
.measureText(line));
if (lineWidth > maxWidth) {
strList.addAll(Cocos2dxBitmap.divideStringWithMaxWidth(
@ -394,7 +374,7 @@ public class Cocos2dxBitmap {
/* Break a String into String[] by the width & should wrap the word. */
for (int i = 1; i <= charLength; ++i) {
tempWidth = (int) FloatMath.ceil(paint.measureText(string, start,
tempWidth = (int) Math.ceil(paint.measureText(string, start,
i));
if (tempWidth >= maxWidth) {
final int lastIndexOfSpace = string.substring(0, i)

View File

@ -157,7 +157,7 @@ public class Cocos2dxEditBoxDialog extends Dialog {
final LinearLayout layout = new LinearLayout(this.getContext());
layout.setOrientation(LinearLayout.VERTICAL);
final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
this.mTextViewTitle = new TextView(this.getContext());
final LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -166,7 +166,7 @@ public class Cocos2dxEditBoxDialog extends Dialog {
layout.addView(this.mTextViewTitle, textviewParams);
this.mInputEditText = new EditText(this.getContext());
final LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
editTextParams.leftMargin = editTextParams.rightMargin = this.convertDipsToPixels(10);
layout.addView(this.mInputEditText, editTextParams);

View File

@ -24,7 +24,6 @@ THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.lib;
import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;

View File

@ -195,7 +195,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
switch (pMotionEvent.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_POINTER_DOWN:
final int indexPointerDown = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT;
final int indexPointerDown = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
final int idPointerDown = pMotionEvent.getPointerId(indexPointerDown);
final float xPointerDown = pMotionEvent.getX(indexPointerDown);
final float yPointerDown = pMotionEvent.getY(indexPointerDown);
@ -232,7 +232,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
break;
case MotionEvent.ACTION_POINTER_UP:
final int indexPointUp = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT;
final int indexPointUp = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
final int idPointerUp = pMotionEvent.getPointerId(indexPointUp);
final float xPointerUp = pMotionEvent.getX(indexPointUp);
final float yPointerUp = pMotionEvent.getY(indexPointUp);
@ -351,7 +351,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
final int actionCode = action & MotionEvent.ACTION_MASK;
sb.append("event ACTION_").append(names[actionCode]);
if (actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP) {
sb.append("(pid ").append(action >> MotionEvent.ACTION_POINTER_ID_SHIFT);
sb.append("(pid ").append(action >> MotionEvent.ACTION_POINTER_INDEX_SHIFT);
sb.append(")");
}
sb.append("[");

View File

@ -30,9 +30,7 @@ import java.util.Locale;
import java.lang.Runnable;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;

View File

@ -26,7 +26,6 @@ package org.cocos2dx.lib;
import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;

View File

@ -315,12 +315,6 @@ static bool _initWithString(const char * text, cocos2d::Device::TextAlign align,
shadowStrokePaddingY = ceilf(info->strokeSize);
}
if ( info->hasShadow )
{
shadowStrokePaddingX = std::max(shadowStrokePaddingX, (float)fabs(info->shadowOffset.width));
shadowStrokePaddingY = std::max(shadowStrokePaddingY, (float)fabs(info->shadowOffset.height));
}
// add the padding (this could be 0 if no shadow and no stroke)
dim.width += shadowStrokePaddingX*2;
dim.height += shadowStrokePaddingY*2;
@ -361,24 +355,8 @@ static bool _initWithString(const char * text, cocos2d::Device::TextAlign align,
: NSTextAlignmentLeft;
// take care of shadow if needed
if ( info->hasShadow )
{
CGSize offset;
offset.height = info->shadowOffset.height;
offset.width = info->shadowOffset.width;
CGFloat shadowColorValues[] = {0, 0, 0, info->shadowOpacity};
CGColorRef shadowColor = CGColorCreate (colorSpace, shadowColorValues);
CGContextSetShadowWithColor(context, offset, info->shadowBlur, shadowColor);
CGColorRelease (shadowColor);
}
CGColorSpaceRelease(colorSpace);
// compute the rect used for rendering the text
// based on wether shadows or stroke are enabled